3

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.
MeanwhileInHell
  • 6,780
  • 17
  • 57
  • 106
  • 3
    `-Xlog:gc=info:file=/var/log/cassandra/gc.log::filecount=10,filesize=10M` should work. Make sure `/var/log/cassandra` directory exists and writable. – apangin Nov 10 '21 at 14:54
  • Thanks for your suggestion. I'm still getting `Invalid -Xlog option '-Xlog:gc=info:file=/var/log/cassandra/gc.log::filecount=10,filesize=10M', see error log for details.` with that. It must be something else at play, what you've suggested should 100% work. Java version is `11.0.11` `Java HotSpot(TM) 64-Bit Server` – MeanwhileInHell Nov 10 '21 at 18:06
  • Look for the error messages *above* this `Invalid -Xlog option` message. Apparently, the JVM cannot create the given file due to some I/O problem. – apangin Nov 10 '21 at 23:38

1 Answers1

0

If this is for getting Cassandra 2.1 to run, the highest Java version you can run it on is Java 8.

If you want to run Cassandra on Java 11, you need to upgrade to Cassandra 4.0 or 4.1.

Aaron
  • 55,518
  • 11
  • 116
  • 132