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

后端 未结 7 2213
攒了一身酷
攒了一身酷 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:35

    Use the RawJsonAppendingMarker:

    log.trace(net.logstash.logback.marker.Markers.appendRaw("jsonMessage", jsonString), null);
    

提交回复
热议问题