How to add gc log

below is the gc logging option to write a specific file

-verbose:gc -Xloggc:/logs/gc.log 

OK Good. but when the java application restarts, the contents of the old gc log in the file disappeared. I hope vm in the file add gc to the file "/logs/gc.log".

Is there an option for this? or do I need to write a shell script to back up the old gc file?

+6
source share
1 answer

You explicitly request that gc data go to a file named "gc.log". You can add a date and pid to the file name to prevent such a collision. The mechanism inside Hotspot does not exist to prevent data overwriting.

+4
source

Source: https://habr.com/ru/post/891929/


All Articles