Node.js set console log location
By default, no console log location is defined for Node.js applications. You can set one using the LSNODE_CONSOLE_LOG environment variable.
Via the cPanel interface
Section titled “Via the cPanel interface”- Navigate to your Node.js application list in cPanel and click Edit on the desired application.
- Under the environment variables section, add:
- Name:
LSNODE_CONSOLE_LOG - Value:
/home/username/pathtoapp/console.log
- Name:
- Save the application. All
console.log()output will now be written to this file.
Via .htaccess
Section titled “Via .htaccess”For more advanced setups, you can define the environment variable in the .htaccess file of your application’s document root:
<IfModule Litespeed>SetEnv LSNODE_CONSOLE_LOG /home/username/nodeapp/console.log</IfModule>To test, add the following to your application code:
console.log('Testing logging');