1
votes

I am using connect-log4j properties for logging when the Kafka JDBC Sink Connector starts. I am trying to override a value from my shell script in connect-log4j.properties.

My Shell Script:

echo "Starting consumer"

/bin/connect-distributed -daemon /connect/connect-distributed.properties.

My log4j properties:

log4j.rootLogger=INFO, stdout, file base.log.dir=/kafka/logs/

//Get the process.name from Shell script command

process.name=?????

log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=${base.log.dir}/${process.name}.log

I was able to create a log by passing the process.name=test which creates test.log. But I am unable to find any information to override the 'process.name' value from my shell script. Any help is appreciated.

1

1 Answers

0
votes

I suspect you could accomplish what you are trying to do using Log4J MDC? http://www.baeldung.com/mdc-in-log4j-2-logback