Search code examples
javagarbage-collection

Java GC Logs not getting created


I am trying to generate the GC logs for one of my Java processes and I have set the VM arguments in the shell script as follows:

export QUOTE_SERVER_CONFIG=~/conf/config.cfg
source ${QUOTE_SERVER_CONFIG}

jvmargs="-verbose:gc -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCCause -Xloggc:\"${LOGS_DIR}/QSGC202100331.log\""
java -cp ${LIB_DIR}/MyJar.jar:${LIB_DIR}/* com.ravi.MainClass ${HOME_STR}

And this is how my config.cfg file looks like

####################
## PATH VARIABLES ##
####################
export PATH="${PATH}:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/root/bin"
export HOME=~
export HOME_STR="${HOME}/fxstr"
export SCRIPT_DIR="${HOME_STR}/bin"
export LIB_DIR="${HOME_STR}/lib"
export LOGS_DIR="${HOME_STR}/logs/"

However, I am unable to see any GC file getting created when I run the shell script. What am I missing?


Solution

  • You do not pass jvmargs to java.

    Try java ${jvmargs} -cp ${LIB_DIR}/MyJar.jar:${LIB_DIR}/* com.ravi.MainClass ${HOME_STR}