Search code examples
javagarbage-collectiontomcat8terraformamazon-elastic-beanstalk

Enabling garbage collection logging with Elastic Beanstalk Tomcat


In my terraform deployment I have settings

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

In the container options, I can see that the Xms, Xmx and GC settings were applied. But when I download full logs from the container I can not find GC logs anywhere. What could be an issue? I read the answer with the common GC setup, but it does not work in my case. I use Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.1.0

enter image description here


Solution

  • the issue you are facing is permission. You are starting the service under tomcat user so it has no access to that path to create logs.

    Try out this -Xloggc:/var/log/tomcat8/gc.log