From 266686e4c4b6c90b116fef2b4ddce644ce2fded0 Mon Sep 17 00:00:00 2001 From: barbatos2011 <162298485+barbatos2011@users.noreply.github.com> Date: Sat, 15 Aug 2026 15:25:49 +0800 Subject: [PATCH] fix(gc-log): write the GC log under ./logs and guarantee the directory bin/FullNode configures GC logging through gradle/java-tron.vmoptions, which pointed at ./gc.log, while the application writes tron.log under ./logs. The two logs ended up in different places, and in container deployments only ./logs is normally mounted, so the GC log stayed inside the container and was lost with it. Point both vmoptions files at ./logs/gc.log, and create the directory in the launcher before the JVM starts. The mkdir is required rather than cosmetic. java-tron creates ./logs at application startup, which is too late, because JVM logging is initialised first. On JDK 9+ a missing directory is fatal instead of a warning, so on the arm64/JDK 17 build the node would refuse to start: Invalid -Xlog option '-Xlog:gc,gc+heap:file=./logs/gc.log:...' Error: Could not create the Java Virtual Machine. [error][logging] Error opening log file './logs/gc.log': No such file or directory Verified on linux/arm64 (JDK 17.0.19, ZGC): the node starts and gc.log appears in ./logs next to tron.log. Without the mkdir the same configuration fails as shown above. start.sh is left unchanged. It invokes the JVM directly with its own -Xloggc:./gc.log, does not read vmoptions, and its GC log rotation expects that location. --- gradle/java-tron.vmoptions | 2 +- gradle/jdk17/java-tron.vmoptions | 2 +- gradle/unixStartScript.txt | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gradle/java-tron.vmoptions b/gradle/java-tron.vmoptions index cf34689ebdd..3b262167312 100644 --- a/gradle/java-tron.vmoptions +++ b/gradle/java-tron.vmoptions @@ -1,6 +1,6 @@ -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails --Xloggc:./gc.log +-Xloggc:./logs/gc.log -XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:ReservedCodeCacheSize=256m diff --git a/gradle/jdk17/java-tron.vmoptions b/gradle/jdk17/java-tron.vmoptions index 180ff1aa7c7..456825d42b1 100644 --- a/gradle/jdk17/java-tron.vmoptions +++ b/gradle/jdk17/java-tron.vmoptions @@ -1,5 +1,5 @@ -XX:+UseZGC --Xlog:gc,gc+heap:file=gc.log:time,tags,level:filecount=10,filesize=100M +-Xlog:gc,gc+heap:file=./logs/gc.log:time,tags,level:filecount=10,filesize=100M -XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing -XX:MetaspaceSize=256m diff --git a/gradle/unixStartScript.txt b/gradle/unixStartScript.txt index 585998cb8c9..b9cc7fd1dab 100644 --- a/gradle/unixStartScript.txt +++ b/gradle/unixStartScript.txt @@ -50,6 +50,11 @@ APP_BASE_NAME=`basename "\$0"` # JAVA_OPTS='"-Xmx\$MEM" "-Xms\$MEM"' #fi +# The GC log configured in java-tron.vmoptions is written under ./logs, next to +# tron.log. JVM logging is initialised before the application runs, so the +# directory has to exist by now: on JDK 9+ a missing one aborts startup. +mkdir -p ./logs + # Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script. DEFAULT_JVM_OPTS=${defaultJvmOpts} for line in \$(cat \$APP_HOME/bin/java-tron.vmoptions)