
Hi, I'm trying to render an XML Request/Response file using Logback, I want to log a XML request or response according to the logger level.Ex: on Error level: <OldSection> <sectionTitle>Sample Title</sectionTitle> <label> Hello Label </label> <heading>Hi </heading> <NewSection> <section> <InteractionSection> <sectionTitle>Section Title</sectionTitle> <label> Hello </label> <heading>Hi </heading> <para> ... ... </para> </InteractionSection> <section> </NewSection> </OldSection> on Debug level: <OldSection> <sectionTitle>Sample Title</sectionTitle> <label> Hello Label </label> <heading>Hi </heading> <NewSection> <section> <InteractionSection> <sectionTitle>Section Title</sectionTitle> </InteractionSection> <section> </NewSection> </OldSection> on Info level: <OldSection> <sectionTitle>Sample Title</sectionTitle> </OldSection> Any idea if I can use Logback to do that?Thanks.

Yes, logback does this well in fact. I can show you and example of a logback encoder that encodes to a JSON format. You can extend the concept to encode XML just the same. Possibly you could use very similar code to mine and abstract your message formatting into a builder pattern. For my money though, I'd stick with JSON. I'd also steer you toward Logstash and Kibana as a killer combo for dealing with logs--both of these tools are free and open source. I attached some (incomplete WRT to dependencies) code that should get the main point across. Good Luck. Troy
participants (2)
-
gaston sponer
-
Troy Hart