本文整理了Java中org.apache.logging.log4j.ThreadContext.cloneStack()
方法的一些代码示例,展示了ThreadContext.cloneStack()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadContext.cloneStack()
方法的具体详情如下:
包路径:org.apache.logging.log4j.ThreadContext
类名称:ThreadContext
方法名:cloneStack
[英]Returns a copy of this thread's stack.
[中]返回此线程堆栈的副本。
代码示例来源:origin: zstackio/zstack
private Runnable saveThreadContext() {
ThreadContextMapSaved savedThread = new ThreadContextMapSaved();
savedThread.contextMap = ThreadContext.getContext();
savedThread.contextStack = ThreadContext.cloneStack();
return () -> {
ThreadContext.clearAll();
ThreadContext.putAll(savedThread.contextMap);
ThreadContext.setStack(savedThread.contextStack.asList());
};
}
代码示例来源:origin: org.apache.logging.log4j/log4j12-api
/**
* Clone the diagnostic context for the current thread.
* <p/>
* <p>Internally a diagnostic context is represented as a stack. A
* given thread can supply the stack (i.e. diagnostic context) to a
* child thread so that the child can inherit the parent thread's
* diagnostic context.
* <p/>
* <p>The child thread uses the {@link #inherit inherit} method to
* inherit the parent's diagnostic context.
*
* @return Stack A clone of the current thread's diagnostic context.
*/
public static Stack cloneStack() {
return org.apache.logging.log4j.ThreadContext.cloneStack();
}
代码示例来源:origin: org.apache.logging.log4j.adapters/log4j-1.2-api
/**
* Clone the diagnostic context for the current thread.
* <p/>
* <p>Internally a diagnostic context is represented as a stack. A
* given thread can supply the stack (i.e. diagnostic context) to a
* child thread so that the child can inherit the parent thread's
* diagnostic context.
* <p/>
* <p>The child thread uses the {@link #inherit inherit} method to
* inherit the parent's diagnostic context.
*
* @return Stack A clone of the current thread's diagnostic context.
*/
public static Stack cloneStack() {
final Stack<String> stack = new Stack<String>();
for (final String element : org.apache.logging.log4j.ThreadContext.cloneStack().asList()) {
stack.push(element);
}
return stack;
}
代码示例来源:origin: org.apache.logging.log4j/log4j-1.2-api
/**
* Clone the diagnostic context for the current thread.
* <p>
* Internally a diagnostic context is represented as a stack. A
* given thread can supply the stack (i.e. diagnostic context) to a
* child thread so that the child can inherit the parent thread's
* diagnostic context.
* </p>
* <p>
* The child thread uses the {@link #inherit inherit} method to
* inherit the parent's diagnostic context.
* </p>
* @return Stack A clone of the current thread's diagnostic context.
*/
@SuppressWarnings("rawtypes")
public static Stack cloneStack() {
final Stack<String> stack = new Stack<>();
for (final String element : org.apache.logging.log4j.ThreadContext.cloneStack().asList()) {
stack.push(element);
}
return stack;
}
代码示例来源:origin: ops4j/org.ops4j.pax.logging
/**
* Constructor.
* @param loggerName The name of the Logger.
* @param marker The Marker or null.
* @param loggerFQCN The fully qualified class name of the caller.
* @param level The logging Level.
* @param message The Message.
* @param properties the properties to be merged with ThreadContext key-value pairs into the event's ReadOnlyStringMap.
* @param t A Throwable or null.
*/
// This constructor is called from LogEventFactories.
public Log4jLogEvent(final String loggerName, final Marker marker, final String loggerFQCN, final Level level,
final Message message, final List<Property> properties, final Throwable t) {
this(loggerName, marker, loggerFQCN, level, message, t, null, createContextData(properties),
ThreadContext.getDepth() == 0 ? null : ThreadContext.cloneStack(), // mutable copy
0, // thread name
null, // stack trace element
0,
null, // LOG4J2-628 use log4j.Clock for timestamps
// LOG4J2-744 unless TimestampMessage already has one
message instanceof TimestampMessage ? ((TimestampMessage) message).getTimestamp() :
CLOCK.currentTimeMillis(), nanoClock.nanoTime());
}
代码示例来源:origin: ops4j/org.ops4j.pax.logging
result.setThrown(t);
result.setContextData(injector.injectContextData(properties, (StringMap) result.getContextData()));
result.setContextStack(ThreadContext.getDepth() == 0 ? ThreadContext.EMPTY_STACK : ThreadContext.cloneStack());// mutable copy
result.setTimeMillis(message instanceof TimestampMessage
? ((TimestampMessage) message).getTimestamp()
内容来源于网络,如有侵权,请联系作者删除!