How to log NODE stderr to own file

Hey guys!

I'm using OLS to run node on thousands of applications and servers, but they are all logging errors to the default stderr file: /usr/local/lsws/logs/stderr.log
I need a way to log each application to a different file, similar to what we did using PHP here:

I tried something like this, but it didn't work:
context / {
  type                    appserver
  env                     LSAPI_STDERR_LOG=/srv/
  include                 /srv/
  location                /srv/
  binPath                 /var/www/.virtualenvs/
  appType                 node
  startupFile             index.js
  addDefaultCharset       off
I tried to use LSNODE_CONSOLE_LOG as an env to log things to a specific file, but also didn't work.

Do you know a better way to handle this with node?

Thanks! :D
I believe that you can set, in the 'Environment' configuration of your node app server virtual host context definition the environment variable

Let us know if that doesn't work out for you.
Sorry, my prior message was incorrect; there currently is no way to do it with OpenLitespeed. However, it can be done with Enterprise Litespeed by setting the environment variable LS_STDERR_LOG=<fully qualified file name> in the Environment configuration of the node app server definition. Our primary developer decided it ought to be in OpenLitespeed as well, so it got added and will be in the next 1.5.x version of OpenLitespeed as well. Look for the text "[FEATURE] add support for LS_STDERR_LOG environment to setup stderr log file for started process." in a version to be released shortly. I've tested it and it's nice. Note that it's only for those messages that are written to stderr like console.error() messages.

Hi rperper.

That's great news! Thank you very much! :D
Well, I guess it's time to start writing my next article about configuring node logs on OLS to help the community :p

Thanks again!


New Member
Just to let you know that v1.5.8 has been released and it includes support for the redirection using LS_STDERR_LOG that we discussed. Give it a try - if you have any problems, please let us know.