Knowledgebase: PHP / Programming
Node.js Set Console Log Location
Posted by Tony B., Last modified by Tony B. on 28 November 2022 02:13 PM

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:

Name: LSNODE_CONSOLE_LOG
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
</IfModule>

(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).