Cp-docker-images: Question: How to disable GC logging

Created on 9 Jul 2018  路  2Comments  路  Source: confluentinc/cp-docker-images

All log files are included in the upstream log4j.properties, but kafkaServer-gc.log.* is missing. In our installation we see these files being accumulated:

root@<pod>:/var/log/kafka$ ls -la
total 789020
drwxr-x--- 2 cp-kafka confluent       238 Jul  8 22:50 .
drwxr-xr-x 6 root     root            166 May 24 00:38 ..
-rw-r--r-- 1 root     root      104858254 Jul  4 08:25 kafkaServer-gc.log.0
-rw-r--r-- 1 root     root      104857828 Jul  5 03:07 kafkaServer-gc.log.1
-rw-r--r-- 1 root     root      104857844 Jul  5 21:34 kafkaServer-gc.log.2
-rw-r--r-- 1 root     root      104858475 Jul  6 15:58 kafkaServer-gc.log.3
-rw-r--r-- 1 root     root      104859142 Jul  7 10:15 kafkaServer-gc.log.4
-rw-r--r-- 1 root     root      104857893 Jul  8 04:32 kafkaServer-gc.log.5
-rw-r--r-- 1 root     root      104858204 Jul  8 22:50 kafkaServer-gc.log.6
-rw-r--r-- 1 root     root       45897083 Jul  9 06:50 kafkaServer-gc.log.7.current

So, why do we log this? The confluent image script does not seem to include GC logging:

https://github.com/confluentinc/cp-docker-images/blob/master/debian/kafka/include/etc/confluent/docker/log4j.properties.template

The relevant arguments of the current command-line are:

-Xloggc:/var/log/kafka/kafkaServer-gc.log
-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=10
-XX:GCLogFileSize=100M

The /usr/bin/kafka-run-class script currently in this container comes from upstream Kafka. The confluent image is running on Java 1.8 - so line 284 will be the one:

https://github.com/apache/kafka/blob/e9f6f2bdcef91f79d128e75e91a1184461ec3de6/bin/kafka-run-class.sh#L281-L286

We actually check for the existence of a -loggc argument, which I cannot find in the image:

https://github.com/apache/kafka/blob/e9f6f2bdcef91f79d128e75e91a1184461ec3de6/bin/kafka-run-class.sh#L251

And only if ${GC_LOG_ENABLED} is true, we actually append the configuration:

https://github.com/apache/kafka/blob/e9f6f2bdcef91f79d128e75e91a1184461ec3de6/bin/kafka-run-class.sh#L269

So, my question is: Why are these arguments appended? How can we disable them?

Most helpful comment

From taking a look at bin/kafka-run-class.sh, it seems that if the environment variable KAFKA_GC_LOG_OPTS is defined, then it is used instead of the command-line arguments mentioned above (i.e. -Xloggc:/var/log/kafka/kafkaServer-gc.log -verbose:gc ...). So setting it to an "innocent" value will stop verbose GC logging. I use:

export KAFKA_GC_LOG_OPTS=-Dnogclog

Of course this is only a workaround.

All 2 comments

Any update on this? I, too, am running into this issue.

From taking a look at bin/kafka-run-class.sh, it seems that if the environment variable KAFKA_GC_LOG_OPTS is defined, then it is used instead of the command-line arguments mentioned above (i.e. -Xloggc:/var/log/kafka/kafkaServer-gc.log -verbose:gc ...). So setting it to an "innocent" value will stop verbose GC logging. I use:

export KAFKA_GC_LOG_OPTS=-Dnogclog

Of course this is only a workaround.

Was this page helpful?
0 / 5 - 0 ratings