Thursday 22 August 2019

[Help] Winston logging

I'm not sure if questions like this are allowed in this sub, but I couldn't find a better place to ask.I want to log different levels to different files as you can see in the code. The problem is Winston logs all of info, debug, warn and error in the `INFO_LOG_PATH` file. I understand that there's a hierarchy in log levels and that all logs that are below the current level are logged in that file.Is there a way I can make strict log levels so that each file only receive logs for one particular predefined level ?const logger = winston.createLogger({ level: 'verbose', format: winston.format.simple(), defaultMeta: { service: 'user-service' }, transports: [ new winston.transports.File({ filename: INFO_LOG_PATH, level: 'info' }), new winston.transports.File({ filename: DEBUG_LOG_PATH, level: 'debug' }), new winston.transports.File({ filename: WARN_LOG_PATH, level: 'warn' }), new winston.transports.File({ filename: ERROR_LOG_PATH, level: 'error' }), ], });

Submitted August 22, 2019 at 07:37AM by Ncell50

No comments:

Post a Comment