Node.js Set Console Log Location Print

  • 0

By default there is no console location defined for Node.js applications. You can define one by setting an environmental variable LSNODE_CONSOLE_LOG and the desired location of your log file. To set an environmental variable you navigate to your Node.js application list and click edit on the desired application. On this page there will be an option to define environment variables:

You will add the following:

Value: /home/username/pathtoapp/console.log

Adjust the value according to the desired location of your console.log. After you've set a value save your Node.js application and any further console activity will be written to the log file. You can test this by inserting the following code:

console.log('Testing logging');

For more advanced users you can also define the environment variable within the .htaccess file of the document root of your Node.js application. The format of that would be as follows:

<IfModule Litespeed>
SetEnv LSNODE_CONSOLE_LOG /home/username/nodeapp/console.log

Hjalp dette svar dig?

« Tilbage

Ready to get started? Build your site from