更换日志框架 flink 1.18
1 消除基础flink框架log4j 添加logback jar
bash
1-1 log4j
log4j-1.2-api-2.17.1.jar
log4j-api-2.17.1.jar
log4j-core-2.17.1.jar
log4j-slf4j-impl-2.17.1.jar
1-2 logback
logback-core-1.2.3.jar
logback-classic-1.2.3.jar
slf4j-api-1.7.25.jar
2 在镜像制作的时候消除:
bash
RUN rm -rf $FLINK_HOME/lib/log4j-1.2-api-2.17.1.jar
RUN rm -rf $FLINK_HOME/lib/log4j-api-2.17.1.jar
RUN rm -rf $FLINK_HOME/lib/log4j-core-2.17.1.jar
RUN rm -rf $FLINK_HOME/lib/log4j-slf4j-impl-2.17.1.jar
RUN rm -rf $FLINK_HOME/lib/log4j-1.2-api-2.17.1.jar
COPY logback-core-1.2.3.jar $FLINK_HOME/lib
COPY logback-classic-1.2.3.jar $FLINK_HOME/lib
COPY slf4j-api-1.7.25.jar $FLINK_HOME/lib
3-2 制作flink yaml的时候添加参数
yaml
logConfiguration:
logback-console.xml: '<configuration> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.file}</file> <Prudent>false</Prudent> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{60} %X{sourceThread} - %msg%n</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.file}.%d{yyyy-MM-dd.HH.mm}</fileNamePattern> <MaxHistory>15</MaxHistory> </rollingPolicy> </appender> <appender name="localfile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>/opt/flink/log/${log.file}</file> <append>false</append> <Prudent>true</Prudent> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{60} %X{sourceThread} - %msg%n</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>/opt/flink/log/${log.file}.%d{yyyy-MM-dd.HH.mm}</fileNamePattern> <MaxHistory>15</MaxHistory> </rollingPolicy> </appender> <root level="DEBUG"> <appender-ref ref="file"/> </root> <logger name="akka" level="INFO"> <appender-ref ref="file"/> </logger> <logger name="org.apache.kafka" level="INFO"> <appender-ref ref="file"/> </logger> <logger name="org.apache.hadoop" level="INFO"> <appender-ref ref="file"/> </logger> <logger name="org.apache.zookeeper" level="INFO"> <appender-ref ref="file"/> </logger> <logger name="org.apache.flink.shaded.akka.org.jboss.netty.channel.DefaultChannelPipeline" level="ERROR"> <appender-ref ref="file"/> </logger></configuration>'