wurstmeister / kafka-docker

Dockerfile for Apache Kafka
http://wurstmeister.github.io/kafka-docker/
Apache License 2.0
6.94k stars 2.73k forks source link

Cannot map environment variables with mixed upper\lower case letters to log4j.properties #325

Open maytals opened 6 years ago

maytals commented 6 years ago

There's not an option to override properties such as: log4j.appender.stateChangeAppender.DatePattern='.'yyyy-MM-dd-HH (in log4j.properties)

The reason is that the property name has an upper case letters in it and in the code all the upper case letters are converted to lowercase letters: https://github.com/wurstmeister/kafka-docker/blob/fcef1c929e0db173fc9e5b1d8f01597d17e9f103/start-kafka.sh#L133

sscaling commented 6 years ago

Yeah, there's probably not a good fix here with breaking backwards compatibility. For a work-around you can use the CUSTOM_INIT_SCRIPT env var to eval custom scripts / code. Alternatively mount through a log4j config file into the /opt/kafka/config/log4j.properties location.

I'll have a think to see if there's anything we can do without having a fragile lookup table / breaking backwards compatibility.

maytals commented 6 years ago

Thank you very much for your quick response.

vogash commented 5 years ago

Is any update about this bug, it is really critical if you want to make advanced log4j configuration

sscaling commented 5 years ago

As per my above comment, there is a work-around. If this is important to you i'd suggest giving the original post a thumbs-up (as currently it only looks like the issues is encountered by one person)

jaceklaskowski commented 4 years ago

I've ran into it just today (and was about to file an issue, but found this).

I wanted to configure the following logger:

log4j.logger.kafka.log.LogManager=ALL

Can you elaborate how to do "Alternatively mount through a log4j config file into the /opt/kafka/config/log4j.properties location."? Thanks.

jaceklaskowski commented 4 years ago

Found it. The following should be in docker-compose.yml:

volumes:
  - ./log4j.properties:/opt/kafka/config/log4j.properties