Logging as json

576 views
Skip to first unread message

Krzysztof Mejka

unread,
Mar 3, 2016, 8:27:53 AM3/3/16
to dropwizard-user
Hello all,
I've got two questions.
1. Simply speaking as in the topic - how can I log messages in json format?
2. If that is not possible, how could I disable the default logging provided by dropwizard? In my company I've got a ready-made logback.xml, which is quite complex and is reused among lots of application by packaging it in a library. I can't use it right now, as during dropwizard startup, when logging is bootstrapped, my whole logback configuration is overriden by whatever is configured by default dropwizard.

Thanks in advance for any support,

Chris

Evan Meagher

unread,
Mar 3, 2016, 12:41:21 PM3/3/16
to dropwiz...@googlegroups.com
You might try the logstash-logback-encoder library, which purports to encode emitted log messages in JSON format: https://github.com/logstash/logstash-logback-encoder

See the section on logging configuration within Dropwizard's user manual for details on available configuration options: https://dropwizard.github.io/dropwizard/0.7.1/docs/manual/configuration.html#logging

_Request_ logging is configured within the `server` config context, confusingly. To disable request logging, you can remove the default appender like so:

    server:
      requestLog:
        appenders: []

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Evan Meagher

Krzysztof Mejka

unread,
Mar 4, 2016, 5:31:28 AM3/4/16
to dropwizard-user
HI Evan,
First of all thanks for the response. 

Could you elaborate how could I use the logback-encoder library? How can I use it? From the manual (you've posted an old version of it, the newest is https://dropwizard.github.io/dropwizard/0.9.2/docs/manual/configuration.html#logging) I don't see any way how I could use this library.
Is there a possibility to somehow define the logging format using a logback.xml instead of the configuration?

Krzysztof Mejka

unread,
Mar 4, 2016, 5:32:20 AM3/4/16
to dropwizard-user
Additionally - I don't want to disable request logging. I was asking if I could totally disable how dropwizard configures the logging and do it myself completely
Reply all
Reply to author
Forward
0 new messages