I have Spring MVC application running on aws ec2. Now I have decided to move to aws elastic beanstalk and yet exploring it before migrating current application. I had few questions regarding persistent storage and application logging.
My question could be naive but please bear with it :)
I am using log4j for application logging. Log4j appends logs at specified location on hard drive. As elastic beanstalk has no persistent storage (storage will be deleted once instance is terminated) and instances may grow/shrink based on the load rules.
So I am stuck at the following
I have been going through articles describing use of .ebextensions directory. I tried using basic .conf files provided by AWS to tail logs to S3 but no success for my application logs.
Sample script to create application directory places under .ebextensions
commands:
01_create_dir:
test: test ! -d "${DIR}"
command: mkdir "${DIR}"
Referred links :
EBS console displays apache logs for URL access.
I would like to know if there is any ready-made solution provided by AWS already that I failed to search.
From http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html :
Standard output and error streams from processes started with a Procfile are captured in log files named after the process and stored in /var/log. For example, the web process in the preceding example generates logs named web-1.log and web-1.error.log for stdout and stderr, respectively.
Based on that, all you have to do is ensure log4j / logback outputs the logs you want to stdout, i.e. CONSOLE
. With Spring Boot this is the default behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With