Search code examples
javagarbage-collectiongarbage

GC logging : gc+meta option does not work on open jdk 14


-Xlog:gc+meta*=trace,rt*=off:file=gcmetatrace.txt

I tried using the above option to enable GC logging. It does not work. I am using JDK 13. Does meta option work with jdk 13?


Solution

  • I guess meta would be metadata, but I do not know what rt should stand for. All the available tags could be listed by java -Xlog:help -version and there will be a section: Available log tags. Just notice that not all tags can be used on their own (class or your metadata can't).

    If I remove rt (as said, I don't really know what this is supposed to mean) and use:

     "-Xlog:gc+meta*=trace:file=gcmetatrace.txt"
    

    it will fail with:

    [0.006s][error][logging] Invalid tag 'meta' in log selection. Did you mean 'metadata'?
    

    I like this. there is no such tag meta that the VM is aware of, as such it fails. The suggestion is to use metadata, let's try that:

    "-Xlog:gc+metadata*=trace:file=gcmetatrace.txt"
    

    The result is:

    [0.005s][warning][logging] No tag set matches selection: gc+metadata*.
    

    The problem is that not all tags can be used either individually or in some combinations and gc+metadata is one of those. Unfortunately, this is just a warning, the JVM process will start just fine, but the log file will be empty (I wish it would error out too).

    So, to answer your question: meta is not supported (it does not even exist), metadata is supported, but not on its own. I am not aware of a command that would list all available combination of the tags, but I can suggest you could try:

     "-Xlog:metadata=trace:file=gcmetatrace.txt" 
    

    This will provide a warning, since metadata is not supported on it's own, but that will also show the possible combinations (not sure if all, though):

    [0.003s][warning][logging] No tag set matches selection: metadata. Did you mean any of the following? metadata* jfr+metadata* jfr+system+metadata redefine+class+obsolete+metadata