Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write GC log to named pipe in Java 9?

Tags:

java

java-9

Before Java9, we can just specify -Xloggc:/my/named/pipe to log garbage collection messages into a named pipe. However, when specifying -Xlog:gc*:file=/my/named/pipe, JVM 9 complains about the named pipe:

[0.003s][error][logging] Unable to log to file /my/named/pipe,  /my/named/pipe is not a regular file.

We are using Linux RedHat with jdk_9.0.1_x64.

How can we log GC messages to a named pipe in Java 9?

like image 353
user3772724 Avatar asked Jan 10 '18 18:01

user3772724


People also ask

What is XLOG GC *?

-Xlog:gc* Enables printing of detailed messages at every GC. -Xlog:gc:file=<filename> Logs messages with the gc tag to the file name specified. For example the option -Xlog:gc:file=gc.

How do I enable verbose GC in Java?

You can enable verbose GC logs by specifying the -verbose:gc standard option when you start your application. For more information, see standard command-line options. The output of -verbose:gc is printed to STDERR by default. To print the log output to a file, append the -Xverbosegclog option.


1 Answers

Looking at the syntax specified under Unified JVM Logging, could you try replacing the arg from

-xlog:gc*.file=/my/named/pip

to

-Xlog:gc*=info:file=gctrace.txt
           ^  ^          ^
       level  colon   filename

or simply

-Xlog:gc*:file=gctrace.txt // since default level for gc logging is INFO
like image 141
Naman Avatar answered Oct 16 '22 09:10

Naman