How to log NODE stderr to own file

#1
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: https://forum.openlitespeed.org/thr...t-error-log-instead-of-stderr.3895/#post-7013

I tried something like this, but it didn't work:
Code:
context / {
  type                    appserver
  env                     LSAPI_STDERR_LOG=/srv/xxxxxxxxxxxx.configr.cloud/log/lsws/stderr.log
  include                 /srv/xxxxxxxxxxxx.configr.cloud/.env
  location                /srv/xxxxxxxxxxxx.configr.cloud/www
  binPath                 /var/www/.virtualenvs/xxxxxxxxxxxx.configr.cloud/10.13.0/bin/node
  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
 
#2
Paulo,
I believe that you can set, in the 'Environment' configuration of your node app server virtual host context definition the environment variable
NODE_REDIRECT_WARNINGS=(file name)

Let us know if that doesn't work out for you.
Thanks.
 
#3
Paulo,
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.

Thanks.
 
#4
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!
 

rperper

New Member
#5
Paulo,
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.

Thanks.
 
#7
Paulo,
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.

Thanks.
Is there any reference for the same? like where do we need to change for enable/disable LS_STDERR_LOG and where can we see those logs etc..
 
Top