Is it possible to do a rolling of garbage collector logs in Sun JVM?
Currently I generate logs using:
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -verbose:gc -Xloggc:gc.log
But I have to manually rotate them using fifo queues and rotatelogs to create a new log for each day. I hope that there is a better solution for this.
Maybe there is a way to access this log entries from inside java so I could redirect them to log4j?
Edit: the solution with fifo queue is not good enough because if the process that reads from this queue (e.g. rotatelogs) reads to slow it will slow down the entire jvm (apparently Sun/Oracle does gc logging synchronously)
Developers take advantage of the JVM argument -XX:+UseGCLogFileRotation to rotate GC log files. As shown above, the JVM will rotate the GC log file whenever its size reaches 20MB. It will generate up to five files, with extensions gc. log.
The typical CUI GC monitoring method involves using a separate CUI application called "jstat", or selecting a JVM option called "verbosegc" when running JVM. GUI GC monitoring is done by using a separate GUI application, and three most commonly used applications would be "jconsole", "jvisualvm" and "Visual GC".
The “Times” section of the detailed log contains information about the CPU time used by the GC, separated into user space (“user”) and kernel space (“sys”) of the operating system. Also, it shows the real time (“real”) that passed while the GC was running.
Built-in support for GC log rotation has been added to the HotSpot JVM. It is described in the RFE 6941923 and is available in:
There are three new JVM flags that can be used to enable and configure it:
-XX:+UseGCLogFileRotation
-Xloggc:<filename>
;-XX:NumberOfGCLogFiles=<number of files>
-XX:GCLogFileSize=<number>M (or K)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With