What's the best practice to send logs to graylog from a JVM application which runs within a docker container? What's the best practice to send logs to graylog from a JVM application which runs within a docker container? docker docker

What's the best practice to send logs to graylog from a JVM application which runs within a docker container?


I'd recommend using an existing GELF appender for the logging framework you're using (e. g. logstash-gelf) instead of logging everything to stdout and use the GELF logging driver of Docker.

Using a proper GELF appender with a native Java logging framework enables you to use advanced features like an MDC to enrich you log messages with valuable structured information without having to re-parse those messages after receiving them on the server side. With the Docker GELF logging driver, you'd only receive log messages line-per-line, which especially with Java applications can be a headache to deal with (think multiline stack traces).

Most logging frameworks support static fields, so that you could "inject" the ID of your Docker container for example.