node.js - log4js - how to specify log file name with an environment variable? -


i using log4js-node log in node js application. want specify path log file name inside log4js config json using environment variable. here config json using:

{     "appenders": [{         "type": "file",         "filename": "${env.api_home}/logs/apiserver_log_file.log",         "maxlogsize": 20480,         "backups": 3,         "category": "apiserver"     }] } 

when application starts, can't find specified path because environment variable not correctly read.

error: enoent, open '${env.api_home}/logs/apiserver_log_file.log' 

how use environment variables correctly inside log4js configuration json?

example:

var log4js = require('log4js');  //console log loaded default, won't need //log4js.loadappender('console'); log4js.loadappender('file'); //log4js.addappender(log4js.appenders.console()); log4js.addappender(log4js.appenders.file('logs/cheese.log'), 'cheese');  var logger = log4js.getlogger('cheese'); logger.setlevel('error');  logger.trace('entering cheese testing'); logger.debug('got cheese.'); logger.info('cheese gouda.'); logger.warn('cheese quite smelly.'); logger.error('cheese ripe!'); logger.fatal('cheese breeding ground listeria.'); 

output:

[2010-01-17 11:43:37.987] [error] cheese - cheese ripe! [2010-01-17 11:43:37.990] [fatal] cheese - cheese breeding ground listeria.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -