Я использую Winston (3.0.0rc5) внутри loopback. У меня есть следующий файл Winston.js:
/* eslint-disable max-len */
'use strict';
var appRoot = require('app-root-path');
var winston = require('winston');
const {colorize, combine, timestamp, printf} = winston.format;
// Define your custom format with printf.
const timeStampFormat = printf(info => {
return `[${info.timestamp}] ${info.level}: ${info.message}`;
});
// define the custom settings for each transport (file, console)
var options = {
info: {
format: combine(
timestamp(),
timeStampFormat
),
level: 'info',
filename: `${appRoot}/logs/access.log`,
handleExceptions: false,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false,
},
error: {
format: combine(
timestamp(),
timeStampFormat
),
level: 'error',
filename: `${appRoot}/logs/error.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false,
},
console: {
format: combine(
timestamp(),
colorize(),
timeStampFormat
),
level: 'debug',
handleExceptions: true,
json: false,
colorize: true,
},
};
// instantiate a new Winston Logger with the settings defined above
var logger = new winston.createLogger({
transports: [
new winston.transports.File(options.info),
new winston.transports.File(options.error),
new winston.transports.Console(options.console),
],
exitOnError: false, // do not exit on handled exceptions
});
module.exports = logger;
Файлы error.log и access.log создаются нормально. В error.log не отображаются ожидаемые информационные сообщения. Однако файл access.log показывает сообщения об ошибках, хотя я установил для handleExceptions значение false.
Как я могу это решить?