Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect verbose garbage collection output to a file?

How do I redirect verbose garbage collection output to a file? Sun’s website shows an example for Unix but it doesn't work for Windows.

like image 529
djangofan Avatar asked Jul 21 '09 20:07

djangofan


People also ask

What is verbose garbage collection?

Verbose garbage collection (verboseGC) is a setting in the Java Virtual Machine configuration of a WebSphere server type, such as a Deployment Manager or Application Server, which controls whether a server JVM will log Garbage Collector diagnostic data in a manner specific to WebSphere Application Server.

How do you read verbose GC logs?

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.

What is PrintGCDateStamps?

2.3. First, -XX:+PrintGCDateStamps adds the date and time of the log entry to the beginning of each line. Second, -XX:PrintGCTimeStamps adds a timestamp to every line of the log detailing the time passed (in seconds) since the JVM was started.


2 Answers

From the output of java -X:

     -Xloggc:<file>    log GC status to a file with time stamps 

Documented here:

-Xloggc:filename

Sets the file to which verbose GC events information should be redirected for logging. The information written to this file is similar to the output of -verbose:gc with the time elapsed since the first GC event preceding each logged event. The -Xloggc option overrides -verbose:gc if both are given with the same java command.

Example:

    -Xloggc:garbage-collection.log

So the output looks something like this:

 0.590: [GC 896K->278K(5056K), 0.0096650 secs] 0.906: [GC 1174K->774K(5056K), 0.0106856 secs] 1.320: [GC 1670K->1009K(5056K), 0.0101132 secs] 1.459: [GC 1902K->1055K(5056K), 0.0030196 secs] 1.600: [GC 1951K->1161K(5056K), 0.0032375 secs] 1.686: [GC 1805K->1238K(5056K), 0.0034732 secs] 1.690: [Full GC 1238K->1238K(5056K), 0.0631661 secs] 1.874: [GC 62133K->61257K(65060K), 0.0014464 secs] 
like image 150
Michael Myers Avatar answered Oct 06 '22 02:10

Michael Myers


If in addition you want to pipe the output to a separate file, you can do:

On a Sun JVM:

-Xloggc:C:\whereever\jvm.log -verbose:gc -XX:+PrintGCDateStamps 

ON an IBM JVM:

-Xverbosegclog:C:\whereever\jvm.log  
like image 41
Marc Giombetti Avatar answered Oct 06 '22 01:10

Marc Giombetti