推荐个查询JVM参数的网站

VM Options Explorer

JDK8 日志参数配置

# 建议
-XX:+PrintGCDetails 
-XX:+PrintGCDateStamps 
-XX:+PrintTenuringDistribution 
-XX:+PrintHeapAtGC 
-XX:+PrintReferenceGC 
-XX:+PrintGCApplicationStoppedTime

# 可选
-XX:+PrintSafepointStatistics 
-XX:PrintSafepointStatisticsCount=1

# GC日志输出的文件路径 %t代表当前时间
-Xloggc:/path/to/gc-%t.log
# 开启日志文件分割
-XX:+UseGCLogFileRotation 
# 最多分割几个文件,超过之后从头文件开始写
-XX:NumberOfGCLogFiles=14
# 每个文件上限大小,超过就触发分割
-XX:GCLogFileSize=100M

JDK11 日志参数配置

配置格式:

-Xlog[:[what][:[output][:[decorators][:output-options[,...]]]]]

如果不配置,默认的是:

-Xlog:all=warning:stdout:uptime,level,tags

对于输出到文件可以配置output-optionsfilecount=32,filesize=64M这个表示保留32个文件,每个文件64M

#建议配置
-Xlog:gc*:file=/logs/gc/gc-%t.log:utctime,pid,tags:filecount=32,filesize=64m