terse-logback icon indicating copy to clipboard operation
terse-logback copied to clipboard

Structured logging vs console output

Open skjolber opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. We have been using structured logging directly to console for quite some time for our kubernetes JVMs. However it seems the current implementation of this library only supports JSON to file.

Describe the solution you'd like Support JSON output to console as well, for deployed (production) workloads. For local development, we like plain old one-line logging. Unit testing against resulting JSON output should still work in development.

Describe alternatives you've considered None

Additional context Our agent requires "one linebreak per log statement".

skjolber avatar Feb 21 '22 21:02 skjolber

The logback-structured-config module is a packaging of logstash-logback-encoder that writes to a file amongst other things, but it's possible to set up the encoder to write to CONSOLE in exactly the same way.

The documentation at https://tersesystems.github.io/terse-logback/1.0.0/guide/structured-config/ explains how to set up appenders and multiple encoders

https://github.com/tersesystems/terse-logback/blob/master/logback-structured-config/src/main/resources/terse-logback/appenders/jsonfile-appenders.xml

And there's also https://github.com/tersesystems/terse-logback-showcase which shows some more options.

wsargent avatar Apr 14 '22 03:04 wsargent