Java: How to log raw JSON as JSON and avoid escaping during logging with logback / slf4j

后端 未结 7 2285
攒了一身酷
攒了一身酷 2021-02-05 13:09

I\'m using SLF4J with Logback in a JAX-RS application... I want to log to JSON in such a way that my message is not encoded again but printed raw into the logfile:

At t

7条回答
  •  星月不相逢
    2021-02-05 13:39

    I ran into the same problem. I solved it with

              
    

    instead of

    
    

    In my java code I used:

    SRV_PERF_LOGGER.info(net.logstash.logback.marker.Markers.appendRaw("message", jackson.writeValueAsString(dto)), null);
    

提交回复
热议问题