KB Article #182225
HOWTO: Enable timestamps for custom Garbage Collector logs
Problem
How to enable the timestamps in custom Garbage Collector logs with Java 11?
Resolution
Since the 5.5-20220428 (April 2022) update, ST is operating with Java 11 (OpenJDK JRE 11.0.15). In Java 11 some JVM flags for Garbage Collection logging have been removed. This includes:
- PrintGCTimeStamps
- PrintGCDateStamps
You may have noticed that enabling GC Logging by editing the $FILEDRIVEHOME/conf/STStartScriptsConfig and adding:
GC_LOGGING=true
results in the default GC log (written in $FILEDRIVEHOME/var/logs/gc_logs/gc-tm.log) recording the timestamps. This is because of the :time tag, contained in the script which is being called by ST for this operation.
However, this is not the case when custom Garbage Collector logs (i.e. written to a custom location) are desired. In order to include the timestamps in the custom GC log files, the :time tag has to be manually added.
To export the Garbage Collector logs to a custom location add the following line in the $FILEDRIVEHOME/conf/STStartScriptsConfig file:
TM_JAVA_OPTS="-Xlog:gc*:$FILEDRIVEHOME/path/to/dir/jvm_gc_t100.log $TM_JAVA_OPTS"
where $FILEDRIVEHOME/path/to/dir/ should be replaced with the directory, the log file will be stored in.
To enable time and date stamps, add the :time tag, so the line becomes:
TM_JAVA_OPTS="-Xlog:gc*:$FILEDRIVEHOME/path/to/dir/jvm_gc_t100.log:time $TM_JAVA_OPTS"
After the saving the changes (and restarting the TM) the records in the custom log file will contain date and time stamps:
[2022-07-16T01:52:53.429+0300] GC(67) Concurrent Cycle 530.963ms
Note that in case you have enabled both the default annd the custom GC logging, your STStartScriptsConfig file will contain two lines:
GC_LOGGING=true TM_JAVA_OPTS="-Xlog:gc*:$FILEDRIVEHOME/path/to/dir/jvm_gc_t100.log:time $TM_JAVA_OPTS"
and two GC log files will be written - one in the default location, and another in the custom location. Depending on which one is required, the respective line can be commented out or removed from the STStartScriptsConfig file.