I am trying to update some older JVM GC log rotation options to be compatible with Java 11. Previously, using Java 8 I had:
-Xloggc:/var/log/cassandra/gc.log"
-XX:+UseGCLogFileRotation"
-XX:NumberOfGCLogFiles=10"
-XX:GCLogFileSize=10M
However, now the last three are invalid and I have been trying in vain to figure out the correct replacement. I have looked at any number of blogs and SO questions, but cannot get them right.
The last attempt was:
JVM_OPTS="$JVM_OPTS -Xloggc:filesize=10M:filecount=10"
JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log"
which resulted in:
[0.002s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:filesize=10M:filecount=10 instead.
[0.002s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/var/log/cassandra/gc.log instead.
[0.002s][error ][logging] Initialization of output 'file=/var/log/cassandra/gc.log' using options '(null)' failed.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
(Oddly, if i change my option to include the additional :
it tells me its invalid)
I have tried:
-Xlog:gc:none:/var/log/cassandra/gc.log:filesize=10M:filecount=10
-Xlog:gc:none:file=/var/log/cassandra/gc.log:filesize=10M:filecount=10
-Xloggc:/var/log/cassandra/gc.log
-Xlog:gc:::filesize=10M:filecount=10
-Xlog:gc,safepoint:gc.log::filecount=10,filesize=10M
-Xlog:gc*,safepoint:gc.log:time,uptime:filecount=10,filesize=10M
Nothing I have tried works, with either an error of an invalid arg, or the (null)
error above.
All I am trying to achieve is to have my gc.log
files roll over when they hit 10M, keep 10 of them, and to write to /var/log/cassandra/gc.log
.
** EDIT **
Removing the rotation args entirely and just keeping
-Xloggc:/var/log/cassandra/gc.log
gives me the same error
[0.002s][error ][logging] Initialization of output 'file=/var/log/cassandra/gc.log' using options '(null)' failed.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.