Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detailed Java GC logs

The sun JVM outputs detailed GC logs to StdOut when the following args are used.

 -verbose:gc
 -XX:+PrintGCTimeStamps
 -XX:+PrintGCDetails

However, I don't want the output in StdOut and I dont really need the detail for every single GC. Is it possible to access the data used for these logs programatically? I would like to be able to log to my own log file the amount of memory allocated/collected and ideally the average object size over time.

like image 826
mchr Avatar asked Oct 11 '22 02:10

mchr


1 Answers

You need to add

-Xloggc:log_file_name

This file gets reinitialized every time the JVM starts, so dont forget to move it to safe location if you want to keep it for analysis.

A complete list of the many command line options Java understands can be found here for Java 6.

like image 175
fvu Avatar answered Oct 14 '22 03:10

fvu