2

My NodeJS-based service writes multiline logs using console.log to journald. However, logs get broken down on each new line (\n). How can I have a multiline message in a single log entry?

Thank you!

geeko
  • 141
  • 1
  • 5

1 Answers1

0

Newer version or rsyslog (> 8.0 I think) add a configuration option to stop this behavior of converting newlines into \n characters. But because rsyslog is text-based, you can't achieve what you want until you break multiple lines into individual log entries using your own log formatter.

I recommend considering using system journal (journad) which handles newlines as you'd expect. More than that, it allows structured logging. This way, you can send your stacktraces and exception classes or codes into individual fields for easy filtering.

lzap
  • 2,882
  • 2
  • 23
  • 23