flink日志问题

flink实时任务,使用了debug,但taskManager上运行的任务一直没有debug级别的日志,只有info日志。

最终回到flink配置,弄清flink/conf下面的日志配置文件作用

log4j.properties:在yarn模式下,jobManager和taskManager上用的log配置都依赖于它!

log4j-cli.properties:flink run启动时的日志依赖于该配置

log4j-yarn-session.properties:用yarn-session.sh启动时的日志依赖于该配置

logback.xml、logback-console.xml、logback-yarn.xml分别对应上面三个日志文件

所以在具体的flink任务配置debug并不能生效,如果需要看到taskManager,需要修改flink/conf/log4j.properties,比如设置DEBUG等级日志,如下

################################################################################
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

# This affects logging for both user code and Flink

# log4j.rootLogger=INFO, file

log4j.rootLogger=DEBUG, file

# Uncomment this if you want to _only_ change Flink's logging
#log4j.logger.org.apache.flink=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.
log4j.logger.akka=INFO
log4j.logger.org.apache.kafka=INFO
log4j.logger.org.apache.hadoop=INFO
log4j.logger.org.apache.zookeeper=INFO

# Log all infos in the given file
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.file=${log.file}
log4j.appender.file.append=false
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n

# Suppress the irrelevant (wrong) warnings from the Netty channel handler
log4j.logger.org.apache.flink.shaded.akka.org.jboss.netty.channel.DefaultChannelPipeline=ERROR, file

 

 

### 日志配置概述 在 Apache Flink 中,日志记录对于监控应用程序行为、调试问题和性能调优至关重要。默认情况下,Flink 使用 Log4j 作为其日志框架,并提供了灵活的日志配置选项来满足不同场景的需求[^3]。 ### 配置文件位置 为了自定义日志设置,通常需要编辑位于 `$FLINK_HOME/conf` 目录下的 `log4j.properties` 文件。此文件控制着整个 Flink 环境中的日志级别、输出格式及目标等属性[^2]。 ### 主要配置项说明 - **根日志器 (Root Logger)**: 定义全局最低日志等级,默认通常是 INFO 或 WARN。 ```properties log4j.rootLogger=INFO, console ``` - **附加设备 (Appenders)**: 指定日志消息发送到哪里,比如控制台(console)或者文件(file)。 控制台输出样例: ```properties log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.target=System.err log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c{2}: %m%n ``` - **特定包或类别的日志级别**: 可以为某些组件单独设定更详细的日志级别以便于排查问题。 设置 JobManager 的 DEBUG 级别日志为例: ```properties log4j.logger.org.apache.flink.runtime.jobmanager=DEBUG ``` 通过调整上述参数可以实现对生产环境中 Flink 应用程序的有效管理和维护。 ### 实践建议 当修改任何日志配置时,请务必重启 Flink 集群以使更改生效;另外,在高并发环境下应谨慎选择合适的日志级别以免影响系统性能[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值