Flink 1.13.1 Standalone模式下调整日志输出的目录

Flink 1.13.1使用log4j.properties定义了jobmanager、taskmanager等的日志输出:

# Allows this configuration to be modified at runtime. The file will be checked every 30 seconds.
monitorInterval=30

# This affects logging for both user code and Flink
rootLogger.level = INFO
rootLogger.appenderRef.file.ref = MainAppender

# Uncomment this if you want to _only_ change Flink's logging
#logger.flink.name = org.apache.flink
#logger.flink.level = INFO

# The following lines keep the log level of common libraries/connectors on
# log level INFO. The root logger does not override this. You have to manually
# change the log levels here.
logger.akka.name = akka
logger.akka.level = INFO
logger.kafka.name= org.apache.kafka
logger.kafka.level = INFO
logger.hadoop.name = org.apache.hadoop
logger.hadoop.level = INFO
logger.zookeeper.name = org.apache.zookeeper
logger.zookeeper.level = INFO

# Log all infos in the given file
appender.rolling.name = MainAppender
appender.rolling.type = RollingFile
appender.rolling.append = false
appender.rolling.fileName = ${sys:log.file}
appender.rolling.filePattern = ${sys:log.file}.%i
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size = 50MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 7

# Suppress the irrelevant (wrong) warnings from the Netty channel handler
logger.netty.name = org.apache.flink.shaded.akka.org.jboss.netty.channel.DefaultChannelPipeline
logger.netty.level = OFF

日志文件的输出路径,使用了变量${sys:log.file}的值,默认输出到了Flink安装路径下的log目录下。

由于Flink一般安装在系统盘,这种日志配置,存在把磁盘打爆的隐患,因此需要调整日志输出文件的路径。

经过查询Flink官方的配置文档,可以在flink-conf.yaml中增加如下配置以调整日志文件的输出目录:

配置项:env.log.dir

配置项说明:Defines the directory where the Flink logs are saved. 
It has to be an absolute path.
(Defaults to the log directory under Flink’s home)

比如:

 

posted @ 2021-09-21 10:11  静若清池  阅读(143)  评论(0编辑  收藏  举报