Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 a 的 appender 中logback.xml是否可以执行任何操作,例如遍历 MDC、打印整个 MDC 等?我能想到的最简单的方法基本上是通过 java/groovy 代码(我还没有研究过如何去做),想知道是否有速记。
logback.xml
如果您正在使用 patternlayout 使用%mdc应该工作。例如:
%mdc
"%d [%thread] %-5level %logger{36} - %msg %mdc%n"
Logback 在此处包含有关 MDC 的故障扩展页面。
就我个人而言,我从未处理过它,但手册中的所有代码示例都显示它是通过 Java 代码访问的,事实上,在第 3 段之后,它开始介绍用于访问 MDC 的示例代码,这让我相信它没有简写.
您可以在此处访问 MDC 类的 Javadoc 。