Why are there extra logs in /tmp under -XX:+LogCompilation?

44 Views Asked by At

When logging compilation on hotspot when running under -XX:+LogCompilation -XX:LogFile=/path/to/file.log logs get written to /path/to/file.log which is good, but also different (much more) logs are written to two /tmp/hs_c<someid>_pid<mypid>.log files, which I didn't expect. When terminating the application, one of those files gets deleted, but the other stays there.

What's going on, and how can I keep the logging to the given log file but stop the logging to the /tmp files?

1

There are 1 best solutions below

0
apangin On

When -XX:+LogCompilation is on, HotSpot logs global compilation events (e.g., when a new compilation task is submitted or when a new compiled method is created) as well as detailed compilation activity of each compiler thread.

To avoid mixing up concurrent output of compiler threads, each thread writes its own log to a dedicated temporary file, which gets merged into LogFile after this thread terminates or when the JVM exits. /tmp/hs_cNNN.log files are these per-thread logs. A file may remain undeleted if the JVM terminates abnormally.

If you don't like the verbose output of LogCompilation, try -XX:+PrintCompilation instead. Alternatively, enable Flight Recorder to get JIT-related events recorded in JFR format.