4

I've tried to configure in both eclipse and intelliJ arguments with garbage collection logger for simple test program. Tried different kind of configurations and the log file has not been created.

-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log

The garbage collection I prefer to create log from is G1 if possible.

LamaTo
  • 540
  • 1
  • 8
  • 21
  • 1
    Are you receiving any output at all? What JDK are using? Some of the GC logging options have changed quite a bit starting in Java 9: https://www.oracle.com/technetwork/java/javase/9-notes-3745703.html#JDK-8145092 – KellyM Aug 24 '19 at 19:57

1 Answers1

6

The -X or -XX params are VM options and not program arguments, which makes me think that if you did not get any errors you may have it incorrectly passed to your program.

I get the following when using your params:

Unrecognized VM option 'PrintGCDateStamps'

By removing it, it worked fine and generated gc.log.

Via IDE

enter image description here

Via Command Line

$ java -Xloggc:gc.log com/stackoverflow/Main

-Xloggc is deprecated

<= Java 8 -Xloggc:filename.log

>= Java 9 -Xlog:gc:filename.log

Using -Xloggc with a modern JVM still works but gives a warning:

[0.005s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:gc.log instead.

rbento
  • 9,919
  • 3
  • 61
  • 61