Broker garbage log collection and log rotation
Learn more about broker garbage collection and how garbage log rotation can be configured.
Both broker JVM garbage collection and JVM garbage log rotation is enabled by default in the Kafka version delivered with Runtime. Garbage collection logs are written in the agent process directory by default.
Changing the default directory of garbage collection logs is currently not supported. However, you can configure properties related garbage log rotation.
Garbage log rotation properties can be configured with the Kafka Broker Environment Advanced Configuration Snippet (Safety Valve) property.
- In Cloudera Manager, go to the Kafka service and click Configuration.
- Find the Kafka Broker Environment Advanced Configuration Snippet (Safety Valve) property.
- Add the following line to the property:
Modify the values of as required.
KAFKA_GC_LOG_OPTS="-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"The flags used are as follows:
+UseGCLogFileRotation: Enables garbage log rotation.
-XX:NumberOfGCLogFiles: Specifies the number of files to use when rotating logs.
-XX:GCLogFileSize: Specifies the size when the log will be rotated.
- Click on Save Changes.
- Restart the Kafka service to apply the changes.