使用 Elastic Beanstalk Tomcat 启用垃圾收集日志记录
Enabling garbage collection logging with Elastic Beanstalk Tomcat
在我的 Terraform 部署中,我有设置
setting {
namespace = "aws:elasticbeanstalk:container:tomcat:jvmoptions"
name = "Xms"
value = "2048m"
}
setting {
namespace = "aws:elasticbeanstalk:container:tomcat:jvmoptions"
name = "Xmx"
value = "2048m"
}
setting {
namespace = "aws:elasticbeanstalk:container:tomcat:jvmoptions"
name = "JVM Options"
value = "-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintTenuringDistribution -Xloggc:log/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=100M"
}
在容器选项中,我可以看到应用了 Xms
、Xmx
和 GC 设置。但是当我从容器下载完整日志时,我无法在任何地方找到 GC 日志。可能是什么问题?我用常见的 GC 设置阅读了 answer,但它在我的情况下不起作用。我用 Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.1.0
您遇到的问题是权限问题。您正在 tomcat
用户下启动该服务,因此它无权访问该路径来创建日志。
试试这个 -Xloggc:/var/log/tomcat8/gc.log
在我的 Terraform 部署中,我有设置
setting {
namespace = "aws:elasticbeanstalk:container:tomcat:jvmoptions"
name = "Xms"
value = "2048m"
}
setting {
namespace = "aws:elasticbeanstalk:container:tomcat:jvmoptions"
name = "Xmx"
value = "2048m"
}
setting {
namespace = "aws:elasticbeanstalk:container:tomcat:jvmoptions"
name = "JVM Options"
value = "-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintTenuringDistribution -Xloggc:log/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=100M"
}
在容器选项中,我可以看到应用了 Xms
、Xmx
和 GC 设置。但是当我从容器下载完整日志时,我无法在任何地方找到 GC 日志。可能是什么问题?我用常见的 GC 设置阅读了 answer,但它在我的情况下不起作用。我用 Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.1.0
您遇到的问题是权限问题。您正在 tomcat
用户下启动该服务,因此它无权访问该路径来创建日志。
试试这个 -Xloggc:/var/log/tomcat8/gc.log