AWS Elastic Beanstalk NodeJS and logs
I want to migrate my NodeJS project from single EC2 to ElasticBeanstalk. In my current code I use the dependency log4js which create a log file on the filesystem. On EC2 this works create but what is the best way in ElasticBeanstalk to log something? If I download the generated logs from ElasticBeanstalk my custom log file from log4js isn’t present.
One Solution collect form web for “AWS Elastic Beanstalk NodeJS and logs”
In order to see the logs you can:
- Press on your elastic beanstalk environment
- Press ‘Logs’ (on the left side)
- Press ‘Request Logs’ (usually just last 100 lines should be fine) and download the file.
You can see a few different log files there.
I believe that logs you write using log4js in Node.js will be under:
I like to ssh into the elastic beanstalk instance and tail the log to see it updating “live” (when I use my server). to do it run the following:
tail -n 50 -f /var/log/nodejs/nodejs.log
In general, when you deploy to Elastic Beanstalk linux environment your app will be under:
Try finding your log files under this path- they will have the same name as when you run the app locally.