日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

log(一)——MDC入门

發布時間:2024/3/13 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 log(一)——MDC入门 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?1.MDC是什么

先來一段原版注釋,

/*** This class hides and serves as a substitute for the underlying logging* system's MDC implementation.* * <p>* If the underlying logging system offers MDC functionality, then SLF4J's MDC,* i.e. this class, will delegate to the underlying system's MDC. Note that at* this time, only two logging systems, namely log4j and logback, offer MDC* functionality. For java.util.logging which does not support MDC,* {@link BasicMDCAdapter} will be used. For other systems, i.e slf4j-simple* and slf4j-nop, {@link NOPMDCAdapter} will be used.** <p>* Thus, as a SLF4J user, you can take advantage of MDC in the presence of log4j,* logback, or java.util.logging, but without forcing these systems as* dependencies upon your users.* * <p>* For more information on MDC please see the <a* href="http://logback.qos.ch/manual/mdc.html">chapter on MDC</a> in the* logback manual.* * <p>* Please note that all methods in this class are static.* * @author Ceki Gülcü* @since 1.4.1*/

這是MDC類上的注釋,但是沒有講這個是干什么的。具體的內容在有一個頁面:

Chapter 8: Mapped Diagnostic Context

簡單來說就是日志的增強功能,如果配置了MDC,并添加了相應的key value,就會在打日志的時候把key對應的value打印出來。

內部是用ThreadLocal來實現的,可以攜帶當前線程的context信息。

2.MDCAdapter——LogbackMDCAdapter

MDC中包裝了一個MDCAdapter,這是一個接口,不同的log包有自己對應的實現。對于不支持MDC的包,比如java.util.logging,使用默認的BasicMDCAdapter,slf4j-nop有NOPMDCAdapter。

這里說的實現是LogbackMDCAdapter。

總結

以上是生活随笔為你收集整理的log(一)——MDC入门的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。