使用Elastic Beanstalk Tomcat启用垃圾收集日志记录

时间:2019-02-08 13:42:51

标签: java garbage-collection tomcat8 terraform amazon-elastic-beanstalk

在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"
  }

在容器选项中,我看到已应用XmsXmx和GC设置。但是,当我从容器中下载完整日志时,在任何地方都找不到GC日志。可能是什么问题?我使用通用的GC设置阅读了answer,但在我的情况下不起作用。我使用Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.1.0

enter image description here

1 个答案:

答案 0 :(得分:1)

您面临的问题是权限。您正在以tomcat用户身份启动服务,因此它无权访问该路径来创建日志。

尝试这个-Xloggc:/var/log/tomcat8/gc.log