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.

Best regards

  • How to set a AWS lambda trigger to Alexa Skills programatically
  • On AWS node socketcluster can't connect more than 1000 connections
  • How do I run PhantomJS on AWS Lambda with NodeJS
  • How to set Open/Download permissions on a file created in S3 with Amazon Lambda?
  • AWS DynamoDB Issue: User is not authorized to perform: dynamodb:PutItem on resource
  • AWS Linux (Ubuntu) hosted application is not accessible from public ip
  • Has anyone been successful deploying a node (express) app with Amazon OpsWorks?
  • Server architecture for a scalable web application
  • sending request to API web service with express (Alexa Top Sites )
  • Why can I not use new XMLHttpRequest on my amazon server?
  • InvalidParameterValueException: The role defined for the function cannot be assumed by Lambda
  • aws DynamoDB gives “write EPROTO”
  • 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:

    /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

    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.

    Node.js is the Best Javascript runtime in the world.