We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
winston
winston@3
node -v
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.
logger.js
'use strict'; /** * This module implements the logger */ 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 * const logger = require('path-to-this-modeule)(__filename) * `__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
<--- JS stacktrace ---> ==== JS stack trace ========================================= Security context: 0x1727b525501 <JSObject> 1: from [buffer.js:~187] [pc=0x3ffa8515ba7d](this=0xb59837bc219 <JSFunction Buffer (sfi = 0x1727b57d7b1)>,value=0x1bc83113a451 <Very long string[287111]>,encodingOrOffset=0x1727b534ea9 <String[4]: utf8>,length=0x3999cba022d1 <undefined>) 2: arguments adaptor frame: 2->3 3: send [/code/node_modules/express/lib/response.js:189] [bytecode=0x1456b5ead069 offset=510](this=... FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: node::Abort() [node] 2: 0x11f155c [node] 3: v8::Utils::ReportOOMFailure(char const*, bool) [node] 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node] 5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [node] 6: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [node] 7: v8::internal::String::Flatten(v8::internal::Handle<v8::internal::String>, v8::internal::PretenureFlag) [node] 8: v8::String::WriteUtf8(char*, int, int*, int) const [node] 9: node::StringBytes::Write(v8::Isolate*, char*, unsigned long, v8::Local<v8::Value>, node::encoding, int*) [node] 10: node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) [node] 11: 0x1211364 [node] 12: 0x3ffa842555e7 Aborted (core dumped)
The text was updated successfully, but these errors were encountered:
@ashuSvirus Have you solved the issue?
Sorry, something went wrong.
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: #2237
No branches or pull requests
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:
###Stack trace
The text was updated successfully, but these errors were encountered: