I am using log4js-node for logs in application. Now what I want is to print the name of user logged in with the time stamp in logs. In java using log4j this could be done using MDC by exporting it and using as:
MDC.put("user",xyz);
How can this be done in nodejs with log4js.
Present:
[2014-06-16 17:24:14.593] [INFO] info - Express server listening on port %d in %s mode', port, app.get('env')
Desired:
[2014-06-16 17:24:14.593] [INFO] [admin] info - Express server listening on port %d in %s mode', port, app.get('env')
Any help would be appreciated. Thanks in advance.
This could be done with some tweeks in the API of log4js. The timestamp is formatted in layout.js. There including the name of user from session might just solve the problem. thanks.