5

I'm running a java application on AWS Elastic Beanstalk (Java 8 running on 64bit Amazon Linux/2.7.4) By default the java application logs to STDOUT and Elastic Beanstalk automatically stores STDOUT in /var/log/web-1.log. This works as expected.

See https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-procfile.html for more information about how Elastic Beanstalk captures and stores STDOUT.

After the web-1.log file reaches a certain size, it gets rotated to /var/log/rotated/web-1.logXXX.gz. However, once this happens, the original web-1.log file is cleared (expected) and no further log messages are written to the file (not expected). All future log messages appear to go directly to a file in the rotated log directory.

Any ideas what might be causing this? I haven't make any changes to the way Elastic Beanstalk handles log rotation.

Matt
  • 828
  • 8
  • 25
angrycrab
  • 830
  • 1
  • 9
  • 23

1 Answers1

-1

Elastic Beanstalk instances (at least the ones I'm using) have the logrotate daemon running. Maybe you can configure it by putting a config file in /etc/logrotate.d?

The problem with the empty log might be a stale file handle from when the log is rotated? See this answer for some examples of how to handle that.

André Laszlo
  • 15,169
  • 3
  • 63
  • 81
  • In EBS there is a working logrotate setup (hourly, with copytruncate) that's behavior is OK but in some cases the log file stays at zero byte size, while the application would put logs there. And after the next rotation, it works again. Meaning there are rare, seemingly random cases of missing log data. – gyorgyabraham Dec 06 '19 at 15:39