bandian
V2EX  ›  问与答

log4j 可以在后期统一在每条日志添加字段吗

  •  
  •   bandian · Oct 19, 2020 · 1155 views
    This topic created in 2039 days ago, the information mentioned may be changed or developed.

    之前的项目使用的 log4j,现在想在每条日志都添加一个字段,查到的解决方案都是一个个 MDC.put(),但是日志太多了,一个一个打显然不现实,所以有没有什么方法可以统一给日志添加字段。这个字段的名字是固定的,但是字段对应的值不是固定的。

    letitbesqzr
        1
    letitbesqzr  
       Oct 19, 2020
    MDC 在拦截器统一加.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1023 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:37 · PVG 03:37 · LAX 12:37 · JFK 15:37
    ♥ Do have faith in what you're doing.