Log rotation distributes GC output across bounded files instead of allowing one file to grow indefinitely. It improves transfer, processing, retention, and disk-space management. section 11.3
Configure rotation around two limits:
- Set filecount to define the maximum number of log files. section 11.3
- Set filesize to limit each file’s size. section 11.3
- When the active file reaches its limit, create an indexed file and continue writing there. section 11.3
- When the file limit is reached, overwrite the oldest file to control total storage. section 11.3
Bound GC logs to five 10 MB files
Run `java -Xlog:gc*:file=logs.txt:time,uptime,level,tags:filecount=5,filesize=10M -jar app.jar`. The JVM starts a new file at 10 MB and overwrites the oldest file after reaching five files. section 11.3
java -Xlog:gc*:file=logs.txt:time,uptime,level,tags:
➥filecount=5,filesize=10M -jar app.jar
Use the complete JVM command as a compact reference for enabling GC logging with rotation. section 11.3



