本文整理了Java中org.apache.log4j.MDC.getContext()
方法的一些代码示例,展示了MDC.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MDC.getContext()
方法的具体详情如下:
包路径:org.apache.log4j.MDC
类名称:MDC
方法名:getContext
[英]Get the current thread's MDC as a hashtable. This method is intended to be used internally.
[中]获取当前线程的MDC作为哈希表。该方法旨在内部使用。
代码示例来源:origin: hibernate/hibernate-orm
@SuppressWarnings("unchecked")
public Map<String, Object> getMdcMap() {
return MDC.getContext();
}
代码示例来源:origin: org.slf4j/slf4j-log4j12
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map getCopyOfContextMap() {
Map old = org.apache.log4j.MDC.getContext();
if (old != null) {
return new HashMap(old);
} else {
return null;
}
}
代码示例来源:origin: org.slf4j/slf4j-log4j12
public void clear() {
@SuppressWarnings("rawtypes")
Map map = org.apache.log4j.MDC.getContext();
if (map != null) {
map.clear();
}
}
代码示例来源:origin: log4j/log4j
/**
Obtain a copy of this thread's MDC prior to serialization or
asynchronous logging.
*/
public
void getMDCCopy() {
if(mdcCopyLookupRequired) {
mdcCopyLookupRequired = false;
// the clone call is required for asynchronous logging.
// See also bug #5932.
Hashtable t = (Hashtable) MDC.getContext();
if(t != null) {
mdcCopy = (Hashtable) t.clone();
}
}
}
代码示例来源:origin: log4j/log4j
/**
Obtain a copy of this thread's MDC prior to serialization or
asynchronous logging.
*/
public
void getMDCCopy() {
if(mdcCopyLookupRequired) {
mdcCopyLookupRequired = false;
// the clone call is required for asynchronous logging.
// See also bug #5932.
Hashtable t = (Hashtable) MDC.getContext();
if(t != null) {
mdcCopy = (Hashtable) t.clone();
}
}
}
代码示例来源:origin: wildfly/wildfly
public Map<String, Object> getMdcMap() {
@SuppressWarnings("unchecked")
final Map<String, Object> map = MDC.getContext();
return map == null ? Collections.<String, Object>emptyMap() : map;
}
代码示例来源:origin: org.slf4j/slf4j-log4j12
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setContextMap(Map contextMap) {
Map old = org.apache.log4j.MDC.getContext();
if (old == null) {
Iterator entrySetIterator = contextMap.entrySet().iterator();
while (entrySetIterator.hasNext()) {
Map.Entry mapEntry = (Map.Entry) entrySetIterator.next();
org.apache.log4j.MDC.put((String) mapEntry.getKey(), mapEntry.getValue());
}
} else {
old.clear();
old.putAll(contextMap);
}
}
}
代码示例来源:origin: pentaho/mondrian
public LoadBatchCommand(
Locus locus,
SegmentCacheManager cacheMgr,
Dialect dialect,
RolapCube cube,
List<CellRequest> cellRequests)
{
this.locus = locus;
this.cacheMgr = cacheMgr;
this.dialect = dialect;
this.cube = cube;
this.cellRequests = cellRequests;
if (MDC.getContext() != null) {
this.mdc.putAll(MDC.getContext());
}
}
代码示例来源:origin: pentaho/mondrian
/**
* Copy the current MDC so it can be used later
*/
public void copyMDC() {
this.mdc.clear();
final Map<String, Object> currentMdc =
MDC.getContext();
if (currentMdc != null) {
this.mdc.putAll(currentMdc);
}
}
代码示例来源:origin: pentaho/mondrian
/**
* Set the copied mdc into the current MDC. This should be called
* any time there will be logging in a thread handled by the
* RolapResultShepherd where original MDC needs to be retrieved
*/
public void setContextMap() {
final Map<String, Object> old = MDC.getContext();
if (old != null) {
old.clear();
old.putAll(mdc);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
Obtain a copy of this thread's MDC prior to serialization or
asynchronous logging.
*/
public
void getMDCCopy() {
if(mdcCopyLookupRequired) {
mdcCopyLookupRequired = false;
// the clone call is required for asynchronous logging.
// See also bug #5932.
Hashtable t = (Hashtable) MDC.getContext();
if(t != null) {
mdcCopy = (Hashtable) t.clone();
}
}
}
代码示例来源:origin: apache/log4j
/**
Obtain a copy of this thread's MDC prior to serialization or
asynchronous logging.
*/
public
void getMDCCopy() {
if(mdcCopyLookupRequired) {
mdcCopyLookupRequired = false;
// the clone call is required for asynchronous logging.
// See also bug #5932.
Hashtable t = MDC.getContext();
if(t != null) {
mdcCopy = (Hashtable) t.clone();
}
}
}
代码示例来源:origin: apache/log4j
/**
Obtain a copy of this thread's MDC prior to serialization or
asynchronous logging.
*/
public
void getMDCCopy() {
if(mdcCopyLookupRequired) {
mdcCopyLookupRequired = false;
// the clone call is required for asynchronous logging.
// See also bug #5932.
Hashtable t = MDC.getContext();
if(t != null) {
mdcCopy = (Hashtable) t.clone();
}
}
}
代码示例来源:origin: pentaho/mondrian
public LoadBatchResponse call() {
if (MDC.getContext() != null) {
final Map<String, Object> old = MDC.getContext();
old.clear();
old.putAll(mdc);
}
return new BatchLoader(locus, cacheMgr, dialect, cube)
.load(cellRequests);
}
代码示例来源:origin: org.jboss.logging/jboss-logging-log4j
@SuppressWarnings("unchecked")
public Map<String, Object> getMap()
{
return MDC.getContext();
}
代码示例来源:origin: apache/activemq-artemis
public Map<String, Object> getMdcMap() {
@SuppressWarnings("unchecked")
final Map<String, Object> map = MDC.getContext();
return map == null ? Collections.<String, Object>emptyMap() : map;
}
代码示例来源:origin: apache/activemq-artemis
public Map<String, Object> getMdcMap() {
@SuppressWarnings("unchecked")
final Map<String, Object> map = MDC.getContext();
return map == null ? Collections.<String, Object>emptyMap() : map;
}
代码示例来源:origin: org.apache.activemq/activemq-all
public void clear() {
@SuppressWarnings("rawtypes")
Map map = org.apache.log4j.MDC.getContext();
if (map != null) {
map.clear();
}
}
代码示例来源:origin: org.slf4j/com.springsource.slf4j.log4j
public void clear() {
Map map = org.apache.log4j.MDC.getContext();
if (map != null) {
map.clear();
}
}
代码示例来源:origin: org.ops4j.pax.logging/pax-logging-service
private void clearDelegateContext()
{
m_service.getConfigLock().readLock().unlock();
if( MDC.getContext() != null )
{
MDC.getContext().clear();
}
}
内容来源于网络,如有侵权,请联系作者删除!