I am trying to configure my Flink application to w...
# troubleshooting
a
I am trying to configure my Flink application to write its logs separately from the TaskManager logs. I attempted to modify the log4j.properties file to achieve this, but so far, I haven’t been successful. The application logs still end up mixed with the TaskManager logs.
d
You need separate appendars defined in log4j. Something like:
Copy code
# Define an appender for your application logs
appender.ApplicationLog.type = RollingFile
appender.ApplicationLog.name = ApplicationLog
appender.ApplicationLog.fileName = ${sys:flink.log.dir}/application.log
appender.ApplicationLog.filePattern = ${sys:flink.log.dir}/application.%d{yyyy-MM-dd}.log.gz
appender.ApplicationLog.layout.type = PatternLayout
appender.ApplicationLog.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
appender.ApplicationLog.policies.type = Policies
appender.ApplicationLog.policies.time.type = TimeBasedTriggeringPolicy
appender.ApplicationLog.policies.time.interval = 1
appender.ApplicationLog.policies.time.modulate = true

# Define the TaskManager appender
appender.TaskManagerLog.type = RollingFile
appender.TaskManagerLog.name = TaskManagerLog
appender.TaskManagerLog.fileName = ${sys:flink.log.dir}/taskmanager.log
appender.TaskManagerLog.filePattern = ${sys:flink.log.dir}/taskmanager.%d{yyyy-MM-dd}.log.gz
appender.TaskManagerLog.layout.type = PatternLayout
appender.TaskManagerLog.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
appender.TaskManagerLog.policies.type = Policies
appender.TaskManagerLog.policies.time.type = TimeBasedTriggeringPolicy
appender.TaskManagerLog.policies.time.interval = 1
appender.TaskManagerLog.policies.time.modulate = true

# Root logger configuration
rootLogger.level = INFO
rootLogger.appenderRef.stdout.ref = STDOUT
rootLogger.appenderRef.ApplicationLog.ref = ApplicationLog
rootLogger.appenderRef.TaskManagerLog.ref = TaskManagerLog
each appender writes to a different path