Open ashuSvirus opened 5 years ago
@ashuSvirus Have you solved the issue?
was it changed only for log.error or should be available with info and debug as well? got the same OOM with large object in log.info
Possibly related, maybe duplicating: https://github.com/winstonjs/winston/issues/2237
Please tell us about your environment:
winston
version?winston@3
node -v
outputs: 9.4.0What is the problem?
I am using elastic-apm to view the system.process.memory.rss.bytes
After some time it goes over 1 GB and node application crashes with following error.
Steps to reproduce:
const DailyRotateFile = require('winston-daily-rotate-file'); const path = require('path'); const { createLogger, format, transports } = require('winston'); const { combine, timestamp, label, errors, json } = format; const pathJoin = path.join; const errorFileName = error.log'; const infoFileName = 'info.log';
// // - Write to all logs with level
info
and below to~info.log
// - Write all logs error (and below) to~error.log
. // const fileLogging = [ new DailyRotateFile({ level: 'error', filename: errorFileName, zippedArchive: false, handleExceptions: true }), new DailyRotateFile({ level: 'info', filename: infoFileName, zippedArchive: false, handleExceptions: true }) ] const logger = caller => { return createLogger({ level: 'info', format: combine( timestamp(), errors({ stack: true }), json() ), defaultMeta: {origin: caller }, transports: [ ...fileLogging ] }); };
class Logger{ constructor (fileName) { this.filename = fileName; this.stream = { write: function(message){ logger(this.filename).info(message); } } } debug (msg, obj) { logger(this.filename).debug(msg, obj); } info (msg, obj){ logger(this.filename).info(msg, obj); } infoDebug (msg, obj) { logger(this.filename).debug(msg, obj); logger(this.filename).info(msg, obj); } warn (msg, obj) { logger(this.filename).warn(msg, obj); } error (msg, obj) { logger(this.filename).error(msg, obj); } } / How to import
__filename
is used to add the location where the logger was called/logged/raised */ const logFn = (...args) => new Logger(...args) module.exports = logFn;Stack trace