node-bunyan
node-bunyan copied to clipboard
Max log length
I use bunyan to log to syslog (stdout > systemd), but if the message logged is too long (e.g. a web service returns an html error page, rather than the expected json) then the json output by bunyan gets split across multiple lines in syslog. Which in turn causes ELK to choke on parsing the log files.
I'm dealing with this by manually truncating the message in places where it has happened (and I've eventually noticed). Would you be open to adding a max message length option? Or is there some existing solution I've missed?
Same happens with fluentd. And if the lines are large enough, it can even crash the log parser.
Was this ever resolved? I'm having the same problem that bunyan is "helping" me by splitting up long messages and changing the syntactic structure in the process. Great feature. How do I shut it off?
I just had that too. Didn't expect such inconsistency...
In my service I'm handling this in a custom stream, which looks for oversized lines and trims fields (large ones first) until it fits: https://gist.github.com/ikonst/9f3070dbd20440646c9d8dca7c184656
Instead of changing bunyan, you can do
bunyan.create({
stream: LogStream({ stream: process.stdout, maxLength: 5000 })
})
I my service we just moved to pino
logger, which has same API :) but also much more flexible. I'd recommend.
how does pino solve this ^^^ problem?