All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nodejs-express-server.logger.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
const { transports, createLogger, format } = require('winston');

const logger = createLogger({
  level: 'info',
  format: format.combine(
    format.timestamp(),
    format.json(),
  ),
  defaultMeta: { service: 'user-service' },
  transports: [
    new transports.Console(),
    new transports.File({ filename: 'error.log', level: 'error', timestamp: true }),
    new transports.File({ filename: 'combined.log', timestamp: true }),
  ],
});

if (process.env.NODE_ENV !== 'production') {
  logger.add(new transports.Console({ format: format.simple() }));
}

module.exports = logger;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy