Winston에서 여러 전송을 사용하려고합니다. 이건 ... 일하고있어. 나는 '감사'의 사용자 지정 수준과 '정보'에 대한 전송과 함께 앱의 감사 로그에 대한 전송을 설정합니다.Winston을 사용하여 여러 파일 전송
var winston_mongo_options = {
level: 'audit', // level that should be logged
safe: true, //makes sure writes happen before firing log event
db: config.db.db, // db in which to write logs
host: config.db.host,
port: config.db.port,
collection: config.db.audit_collection // collection we want logging to occur
};
if (config.db.user) {
winston_mongo_options.username = config.db.user;
winston_mongo_options.password = config.db.pass;
}
var custom_levels = winston.config.syslog.levels;
custom_levels.audit = 8;
var logger = new (winston.Logger)({
levels: custom_levels,
transports : [
new (winston.transports.MongoDB)(winston_mongo_options),
new (winston.transports.File)({
level: 'info',
silent: false,
colorize: true,
timestamp: true,
filename: config.logs.debug,
maxsize: 500000,
maxFiles: 5,
json: true
})
],
exceptionHandlers: [
new (winston.transports.File)({
silent: false,
colorize: false,
timestamp: true,
filename: config.logs.exception,
maxsize: 500000,
maxFiles: 5,
json: true
})
]
});
module.exports.logger = logger;
필자는 로깅을 원하는 위치/시간에이 파일을 필요로합니다. 특정 정보를 로그에 개별적으로 보내려고 할 때 문제가 발생합니다.
logger.audit('Server Started - to DB');
logger.info('Server Started - to info');
이 두 줄은 별도의 로그에 기록해야합니다. 첫 번째 줄은 데이터베이스와 정보 로그 파일에 올바르게 기록됩니다. 내가 도대체 뭘 잘못하고있는 겁니까?