I want to log “pretty printed” XML using Logback/SLF4J.
Right now, what I get in logs is totally unreadable and I have to open something to parse it.
I want to be able to configure logging for debug (because I want to see XML only in debug) to output XML in a human readable way.
Is it possible?
Simply add a newline
\nin log statement:UPDATE: In order to pretty-print XML have a look at: How to pretty print XML from Java?. One thing to keep in mind, there is no need to perform costly formatting if the XML is not going to be actually printed. Therefore this is one of the rare cases where
is*Enabled()should be used: