Node.js log module bunyan change time zone

I use this bunyan.js registration module, which is included in the restify.js framework. The module displays the time in the log / console file, however I want to change the time to UTC / GMT, not sure if it is possible to change the module code?

+5
source share
2 answers

If you do not want to use local time elsewhere in your process, one way to achieve what you want is to change the time zone for the process. Or by writing this expression when starting your application:

process.env.TZ = 'UTC'

Or, by running it using the environment variable from the command line, follow these steps:

TZ=UTC node main.js
0
source

, localtime bunyan.createLogger :

var init = function () {
    log = bunyan.createLogger({
        name: 'myLogs',
        src: true,
        localtime: new Date().toString();
    });
};

, localtime .

, .

0

All Articles