I create a logger middleware with using winston and morgan like below:
const format = winston.format.combine(
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),
winston.format.printf(
(info) => `${info.timestamp} ${info.level}: ${info.message}`,
),
)
const transports = [
new winston.transports.Console(),
new winston.transports.File({
filename: 'logs/error.log',
level: 'error',
}),
new winston.transports.File({ filename: 'logs/all.log' }),
]
const logger = winston.createLogger({
format,
level: "info",
transports
})
const stream = {
write: (message) => logger.log(message),
};
const morganMiddleware = morgan(
":remote-addr :method :url :status :res[content-length] - :response-time ms",
{ stream }
);
app.use(morganMiddleware);
But when my start is running and receive first log, winston throw me this error:
level[LEVEL] = level.level;
^
TypeError: Cannot create property 'Symbol(level)' on string '::1 GET /api/amr/applications?order=ASC&sortBy=application.lastIncidentAt 304 - - 380.459 ms
can someone tell me what is wrong with my winston/morgan configuration?
thanks for any help!