Gaurav
Gaurav

Reputation: 173

how to run my flink job with -Dlog4j.configuration=file:/path/to/log4j.properties on server

I have saved my log4j.properties on server. i want to access that property file when running my flink job on server i dont know how to use "-Dlog4j.configuration=file:/path/to/log4j.properties" with the command to run flink job

command to run flink job is - bin/flink run /opt/Flink/50.jar where should i add "-Dlog4j.configuration=file:/path/to/log4j.properties" in my command

property file contains-

log4j.rootLogger =DEBUG, FILE, FILE2

log4j.appender.FILE =org.apache.log4j.FileAppender

log4j.appender.FILE.File=${my.log1}

log4j.appender.FILE.layout = org.apache.log4j.PatternLayout

log4j.appender.FILE.layout.ConversionPattern =%d{ISO8601} %-5p %c ~ %m%n

log4j.appender.FILE.Threshold = ERROR

log4j.appender.FILE2 = org.apache.log4j.FileAppender

log4j.appender.FILE2.File=${my.log}

log4j.appender.FILE2.layout =org.apache.log4j.PatternLayout

log4j.appender.FILE2.layout.ConversionPattern =%d{ISO8601} %-5p %c ~ %m%n

log4j.appender.FILE2.Threshold = ERROR

Upvotes: 4

Views: 2331

Answers (1)

0x26res
0x26res

Reputation: 13952

If you are using the flink "Standalone Cluster" you want to add this entry to your flink-conf.yaml:

env.java.opts: -Dlog4j.configuration=file:/path/to/log4j.properties

You can also set different config for taskmanager and jobmanager:

env.java.opts.taskmanager: -Dlog4j.configuration=file:/path/to/log4j.properties
env.java.opts.jobmanager: -Dlog4j.configuration=file:/path/to/log4j.properties

This is not a 'per job' config basis, but will be for all jobs.

See the documentation here

Upvotes: 2

Related Questions