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.
Best regards
Open the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list. If you have many environments, use the search bar to filter the environment list. In the navigation pane, choose Logs.
Within the Elastic Beanstalk configuration, you can specify a retention period (e.g. 30 days) before they're deleted. The logs are searchable directly within the AWS Console (within the CloudWatch section).
Elastic Beanstalk provides platforms for programming languages (Go, Java, Node. js, PHP, Python, Ruby), application servers (Tomcat, Passenger, Puma), and Docker containers.
In order to see the logs you can:
You can see a few different log files there.
I believe that logs you write using log4js in Node.js will be under:
/var/log/nodejs/nodejs.log
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:
eb ssh
tail -n 50 -f /var/log/nodejs/nodejs.log
The above log path depends on the type of the EC2. on Linux 2 it is: /var/log/web.stdout.log
In general, when you deploy to Elastic Beanstalk linux environment your app will be under:
/var/app/current
Try finding your log files under this path- they will have the same name as when you run the app locally.
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