bandian
V2EX  ›  问与答

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

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

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

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