Provide service specific log4j overrides in containerized deployments (#13020)

* Provide service specific log4j overrides

* Clarify comments

* Add docs
This commit is contained in:
Atul Mohan 2022-09-13 20:47:11 -07:00 committed by GitHub
parent 54a2eb7dcc
commit a8fd3a9077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -28,7 +28,9 @@
# #
# Additional env vars: # Additional env vars:
# - DRUID_LOG4J -- set the entire log4j.xml verbatim # - DRUID_LOG4J -- set the entire log4j.xml verbatim
# - DRUID_LOG_LEVEL -- override the default log level in default log4j # - DRUID_LOG_LEVEL -- override the default log level in default log4j. This presently works only if the existing log level is INFO
# - DRUID_SERVICE_LOG4J -- set the entire service specific log4j.xml verbatim
# - DRUID_SERVICE_LOG_LEVEL -- override the default log level in the service specific log4j. This presently works only if the existing log level is INFO
# - DRUID_XMX -- set Java Xmx # - DRUID_XMX -- set Java Xmx
# - DRUID_XMS -- set Java Xms # - DRUID_XMS -- set Java Xms
# - DRUID_MAXNEWSIZE -- set Java max new size # - DRUID_MAXNEWSIZE -- set Java max new size
@ -176,6 +178,18 @@ then
echo "$DRUID_LOG4J" >$COMMON_CONF_DIR/log4j2.xml echo "$DRUID_LOG4J" >$COMMON_CONF_DIR/log4j2.xml
fi fi
# Service level log options can be used when the log4j2.xml file is setup in the service config directory
# instead of the common config directory
if [ -n "$DRUID_SERVICE_LOG_LEVEL" ]
then
sed -ri 's/"info"/"'$DRUID_SERVICE_LOG_LEVEL'"/g' $SERVICE_CONF_DIR/log4j2.xml
fi
if [ -n "$DRUID_SERVICE_LOG4J" ]
then
echo "$DRUID_SERVICE_LOG4J" >$SERVICE_CONF_DIR/log4j2.xml
fi
DRUID_DIRS_TO_CREATE=${DRUID_DIRS_TO_CREATE-'var/tmp var/druid/segments var/druid/indexing-logs var/druid/task var/druid/hadoop-tmp var/druid/segment-cache'} DRUID_DIRS_TO_CREATE=${DRUID_DIRS_TO_CREATE-'var/tmp var/druid/segments var/druid/indexing-logs var/druid/task var/druid/hadoop-tmp var/druid/segment-cache'}
if [ -n "${DRUID_DIRS_TO_CREATE}" ] if [ -n "${DRUID_DIRS_TO_CREATE}" ]
then then

View File

@ -78,6 +78,8 @@ Logging configuration:
* `DRUID_LOG4J` -- set the entire [`log4j.xml` configuration file](https://logging.apache.org/log4j/2.x/manual/configuration.html#XML) verbatim. ([Example](https://github.com/apache/druid/blob/{{DRUIDVERSION}}/distribution/docker/environment#L52)) * `DRUID_LOG4J` -- set the entire [`log4j.xml` configuration file](https://logging.apache.org/log4j/2.x/manual/configuration.html#XML) verbatim. ([Example](https://github.com/apache/druid/blob/{{DRUIDVERSION}}/distribution/docker/environment#L52))
* `DRUID_LOG_LEVEL` -- override the default [Log4j log level](https://en.wikipedia.org/wiki/Log4j#Log4j_log_levels) * `DRUID_LOG_LEVEL` -- override the default [Log4j log level](https://en.wikipedia.org/wiki/Log4j#Log4j_log_levels)
* `DRUID_SERVICE_LOG4J` -- set the entire [`log4j.xml` configuration file](https://logging.apache.org/log4j/2.x/manual/configuration.html#XML) verbatim specific to a service.
* `DRUID_SERVICE_LOG_LEVEL` -- override the default [Log4j log level](https://en.wikipedia.org/wiki/Log4j#Log4j_log_levels) in the service specific log4j.
Advanced memory configuration: Advanced memory configuration: