Node.js: Winston: Can I add default meta data to all log messages

For Winston v2 (see comments)

There are now rewriters.

For example, the below will add a property app to every metadata going through this logger.

    logger.rewriters.push(function(level, msg, meta) {
      meta.app = 'myApp';
      return meta;
    });

You can also declare it when building the logger:

    new (winston.Logger)({
            level: config.log[file].level,
            rewriters: [
                (level, msg, meta) => {
                    meta.app = 'myApp';
                    return meta;
                }
            ],
            transports: [
                /*your transports*/
            ]
    });

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)