Garbage-collection (GC) logging is a helpful diagnostic tool for troubleshooting a variety of issues that are related to the performance of microservices in a SAS Viya environment. To enable garbage-collection logging for a microservice in a SAS Viya 3.x environment, follow the instructions below. Note that these instructions apply for Viya 3.x versions only, such as SAS Viya 3.5.
These instructions, for UNIX operating environments, use the generic placeholder microservice-name for any microservice for which you want to enable GC logging in SAS Viya. Replace microservice-name with the name of the microservice of interest that you want to enable GC logging for. A note is added to each step below where modifications are necessary, with examples shown for different microservices.
cd /opt/sas/viya/config/etc/sysconfig/
2. Create a file in that directory named microservice-name.conf. Ensure that this file has the same permissions as the other files and subfolders in that directory.
Note: Name this .conf file such that it reflects the microservice for which you want to enable GC logging. For example, if you are working with the files service, you should create a file named files.conf. Or, if you are working with the SAS logon service, create a file named saslogon.conf.
3. Add the following contents to the microservice-name.conf file that you just created (/opt/sas/viya/config/etc/sysconfig/microservice-name.conf):
export JAVA_OPTION_PRINTGCDETAILS=-XX:+PrintGCDetails
export JAVA_OPTION_PRINTGCTIMESTAMPS=-XX:+PrintGCTimeStamps
export JAVA_OPTION_PRINTGCDATESTAMPS=-XX:+PrintGCDateStamps
export JAVA_OPTION_PRINTHEAPATGC=-XX:+PrintHeapAtGC
export JAVA_OPTION_VERBOSEGC=-verbose:gc
export JAVA_OPTION_LOGGC=-Xloggc:/opt/sas/viya/config/var/log/gc_`basename "$0"`_`date +%d%b%Y_%H.%M.%S`.log
4. Save the file and restart the microservice by submitting the appropriate command on the machine where the microservice runs, as shown below:
sudo service sas-viya-microservice-name-default restart
Note: Restart the applicable service for which you are enabling GC logging. For example, if you are working with the files service and you created a file that is named files.conf, use this command to restart the files service:
sudo service sas-viya-files-default restart
If you are working with the SAS logon service and you have a file that is named saslogon.conf, use this command to restart the service:
sudo service sas-viya-saslogon-default restart
After you restart the services, you should see a file that is named gc_microservice-name_date.log in the /opt/sas/viya/config/var/log directory. Each time you restart the Java virtual machine (JVM), the file name will be updated with the current date and time.
The impact of GC logging on the JVM process is fairly minimal. Therefore, you can safely leave this logging enabled long term if needed.
To disable the GC logging, simply delete the microservice-name.conf file you created in step 2, and then restart the service.
Note: This instruction to delete the microservice-name.conf file assumes that the file does not contain JVM options other than those that enable GC logging. If microservice-name.conf does contain other JVM options file, you can remove only the GC logging options that you added in step 3, rather than deleting the entire file.
These instructions, for Windows operating environments, use the generic placeholder microservice-name for any microservice for which you want to enable GC logging in SAS Viya. Replace microservice-name with the name of the microservice of interest that you want to enable GC logging for. A note is added to each step below where modifications are necessary, with examples shown for different microservices.
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/microservice-name/jvm/JAVA_OPTION_PRINTGCDETAILS -value -XX:+PrintGCDetails
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/microservice-name/jvm/JAVA_OPTION_PRINTGCTIMESTAMPS -value -XX:+PrintGCTimeStamps
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/microservice-name/jvm/JAVA_OPTION_PRINTGCDATESTAMPS -value -XX:+PrintGCDateStamps
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/microservice-name/jvm/JAVA_OPTION_PRINTHEAPATGC -value -XX:+PrintHeapAtGC
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/microservice-name/jvm/JAVA_OPTION_VERBOSEGC -value -verbose:gc
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/microservice-name/jvm/JAVA_OPTION_LOGGC -value -Xloggc:C:\ProgramData\SAS\Viya\var\^
log\gc_microservice-name_^%t.log
For example, here is what one of these commands will look like if you are enabling GC logging for the files service:
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/files/^
jvm/JAVA_OPTION_PRINTGCDETAILS -value -XX:+PrintGCDetails
For example, here is what one of these commands will look like if you are enabling GC logging for the SAS Logon service:
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv write --force -key config/SASLogon/jvm/JAVA_OPTION_PRINTGCDETAILS -value -XX:+PrintGCDetails
If you have any questions about how to properly form these commands for the microservice that you want to enable logging for, contact SAS Technical Support for assistance.
After you restart the service, you should see a file named gc_<microservice_name>_<date>_<time>.log in the C:\ProgramData\SAS\Viya\var\log\ directory. Each time you restart the Java virtual machine (JVM), the file name is updated with the current date and time.
For example, if you are enabling GC logging for the files service, you should restart SAS File Service in Windows Services. Then, you should see a log file named gc_files_<date>_<time>.log.
The impact of GC logging on the JVM process is fairly minimal. Therefore, you can safely leave this logging enabled long term if needed.
To disable the GC logging, use the following steps:
cd C:\Program Files\SAS\Viya\bin
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/microservice-name/jvm/JAVA_OPTION_PRINTGCDETAILS
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/microservice-name/jvm/JAVA_OPTION_PRINTGCTIMESTAMPS
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/microservice-name/jvm/JAVA_OPTION_PRINTGCDATESTAMPS
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/microservice-name/jvm/JAVA_OPTION_PRINTHEAPATGC
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/microservice-name/^
jvm/JAVA_OPTION_VERBOSEGC
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/microservice-name/^
jvm/JAVA_OPTION_LOGGC
For example, here is what one of these commands will look like if you are disabling GC logging for the files service:
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/files/jvm/JAVA_OPTION_PRINTGCDETAILS
For example, here is what one of these commands will look like if you are disabling GC logging for the SAS Logon service:
sas-bootstrap-config --token-file C:\ProgramData\SAS\Viya\etc\SASSecurityCertificateFramework\tokens\^
consul\default\management.token kv delete config/SASLogon/jvm/^
JAVA_OPTION_PRINTGCDETAILS
For example, if you are disabling GC logging for the files service, you should restart SAS File Service in Windows Services. After that, you should no longer see a new gc_<microservice_name>_<date>_<time>.log created in the C:\ProgramData\SAS\Viya\var\log\ directory each time you restart that microservice.