Search code examples
javascriptnode.jsamazon-elastic-beanstalkwinston

Node.js - Elastic Beanstalk - Winston - /var/log/nodejs


We have been using Winston on elastic beanstalk for a while now, it works well. But we are always writing two sets of logs - one is the system node logs, in /var/log/nodejs, and then we have our own application specific files, which are in a log directory in the root of the app. We decided to try consolidating our logs, it makes it convenient to get them in the beanstalk console.

However, /var/log/nodejs/nodejs.log, when a new instance starts up, the permissions on the log are restricted to root, and the app crashes. The nodejs process can't write to them. We can chown the file to nodejs, but that it not a good long term solution. Has anyone got this set up? And if so, how have you done so?


Solution

  • Assuming you are using the file transport.

    If you switch to the console transport the process should write to the standard output which elastic beanstalk will write to the log at /var/log/nodejs/nodejs.log.