下面列出了怎么用org.slf4j.spi.MDCAdapter的API类实例代码及写法,或者点击链接到github查看源代码。
public Map<String, String> getMDCPropertyMap() {
if(this.mdcPropertyMap == null) {
MDCAdapter mdc = MDC.getMDCAdapter();
if(mdc instanceof LogbackMDCAdapter) {
this.mdcPropertyMap = ((LogbackMDCAdapter)mdc).getPropertyMap();
} else {
this.mdcPropertyMap = mdc.getCopyOfContextMap();
}
}
if(this.mdcPropertyMap == null) {
this.mdcPropertyMap = CACHED_NULL_MAP;
}
return this.mdcPropertyMap;
}
/**
* Currently this method always returns an instance of
* {@link StaticMDCBinder}.
* @return
*/
public MDCAdapter getMDCA() {
try {
return (MDCAdapter) Class.forName(getMDCAdapterClassStr()).newInstance();
} catch (Exception e) { // NOSONAR we can't log here as we are actually instantiating log here
System.err.println("Unable to instantiate mdc adapter " + getMDCAdapterClassStr()); // NOSONAR
e.printStackTrace(); // NOSONAR
return new NOPMDCAdapter();
}
}
public static MDCAdapter getInstance() {
return mtcMDCAdapter;
}
public MDCAdapter getMDCA() {
return new BasicMDCAdapter();
}
public static MDCAdapter getInstance() {
return mtcMDCAdapter;
}
private static MDCAdapter bwCompatibleGetMDCAdapterFromBinder() throws NoClassDefFoundError {
return StaticMDCBinder.SINGLETON.getMDCA();
}
public static MDCAdapter getMDCAdapter() {
return mdcAdapter;
}
public MDCAdapter getMDCA() {
return new BasicMDCAdapter();
}
@Override
public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}
public MDCAdapter getMDCA() {
return new ThreadLocalMDCAdapter();
}
Adapter(MDCAdapter delegate) {
this.delegate = requireNonNull(delegate, "delegate");
}
@Override
public synchronized MDCAdapter getMDCAdapter() {
return this.mdc;
}
public static MDCAdapter mdc() {
return SINGLETON.getMDCA();
}
public MDCAdapter getMDCA() {
return adapter;
}
public MDCAdapter getMDCA() {
return new BasicMDCAdapter();
}
@Override
public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}
/**
* Currently this method always returns an instance of
* {@link StaticMDCBinder}.
*/
public MDCAdapter getMDCA() {
return new NOPMDCAdapter();
}
/**
* Currently this method always returns an instance of
* {@link StaticMDCBinder}.
*/
public MDCAdapter getMDCA() {
return new NOPMDCAdapter();
}
/**
* Currently this method always returns an instance of {@link StaticMDCBinder}.
* @return an MDC adapter
*/
public MDCAdapter getMDCA() {
return new Log4jMDCAdapter();
}