本文整理汇总了Java中ch.qos.logback.classic.spi.LoggingEvent.setThreadName方法的典型用法代码示例。如果您正苦于以下问题:Java LoggingEvent.setThreadName方法的具体用法?Java LoggingEvent.setThreadName怎么用?Java LoggingEvent.setThreadName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.spi.LoggingEvent
的用法示例。
在下文中一共展示了LoggingEvent.setThreadName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
public LoggingEvent build(int i) {
LoggingEvent le = new LoggingEvent();
le.setTimeStamp(System.currentTimeMillis());
Object[] aa = new Object[] { i, "HELLO WORLD [========== ]" + i };
le.setArgumentArray(aa);
String msg = MSG + i;
le.setMessage(msg);
// compute formatted message
// this forces le.formmatedMessage to be set (this is the whole point of the
// exercise)
le.getFormattedMessage();
le.setLevel(Level.DEBUG);
le.setLoggerName(logger.getName());
le.setLoggerContextRemoteView(loggerContext.getLoggerContextRemoteView());
le.setThreadName("threadName");
return le;
}
示例2: onLog
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
public void onLog(LogEntry logEntry) {
final LoggingEvent loggingEvent = new LoggingEvent();
loggingEvent.setTimeStamp(logEntry.getTimestamp());
loggingEvent.setLoggerName(logEntry.getLoggerName());
loggingEvent.setLevel(Level.valueOf(logEntry.getLogLevel().name()));
loggingEvent.setThreadName(logEntry.getThreadName());
Object [] formatObjects = new Object[] {logEntry.getHost(),
getSimpleClassName(logEntry.getSourceClassName()),
logEntry.getSourceMethodName(),
logEntry.getFileName(),
logEntry.getLineNumber(),logEntry.getMessage()};
loggingEvent.setMessage(MESSAGE_FORMAT.get().format(formatObjects));
// Prints the throwable and stack trace.
LogThrowable logThrowable = logEntry.getThrowable();
if (logThrowable != null) {
loggingEvent.setThrowableProxy(new ThrowableProxy(setThrowable(logThrowable)));
}
if (logger instanceof Logger) {
((Logger) logger).callAppenders(loggingEvent);
} else {
logger.info("Logger is not instance of ch.qos.logback.classic.Logger. Logger event is: {}", loggingEvent);
}
}
示例3: createLoggingEvent
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private LoggingEvent createLoggingEvent() {
LoggingEvent event = new LoggingEvent("com.example.XMLLayoutTest-<&>'\"]]>", root,
Level.DEBUG, MESSAGE,
new RuntimeException("Dummy exception: <&>'\"]]>"), null);
event.setThreadName("Dummy thread <&>'\"");
event.getMDCPropertyMap().put(MDC_KEY, MDC_VALUE);
StackTraceElement ste1 = new StackTraceElement("c1", "m1", "f1", 1);
StackTraceElement ste2 = new StackTraceElement("c2", "m2", "f2", 2);
event.setCallerData(new StackTraceElement[]{ ste1, ste2} );
return event;
}
示例4: build
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
public Object build(int i) {
LoggingEvent le = new LoggingEvent();
le.setTimeStamp(System.currentTimeMillis());
le.setLevel(Level.DEBUG);
le.setLoggerName(logger.getName());
le.setLoggerContextRemoteView(loggerContext.getLoggerContextRemoteView());
le.setMessage(MSG_PREFIX);
le.setThreadName("threadName");
return le;
}
示例5: testAppendNonTriggeringEvent
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void testAppendNonTriggeringEvent() {
LoggingEvent event = new LoggingEvent();
event.setThreadName("thead name");
event.setLevel(Level.DEBUG);
appender.subAppend(cb, event);
assertEquals(1, cb.length());
}
示例6: createLoggingEvent
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private ILoggingEvent createLoggingEvent() {
LoggingEvent le = new LoggingEvent();
le.setLevel(Level.DEBUG);
le.setMessage("test message");
le.setTimeStamp(System.currentTimeMillis());
le.setThreadName(Thread.currentThread().getName());
return le;
}
示例7: newEvent
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
protected Object newEvent(LogDetails logDetails) {
ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logDetails.getClassName());
LoggingEvent event = new LoggingEvent(this.getClass().getName(), logger, Level.DEBUG, logDetails.getLogMessage(),
logDetails.getException(), null);
event.setThreadName(logDetails.getThreadName());
event.setTimeStamp(logDetails.getTimeMillis());
event.setMDCPropertyMap(logDetails.getMdc());
StackTraceElement callerData = new StackTraceElement(logDetails.getClassName(), logDetails.getMethodName(),
logDetails.getFileName(), logDetails.getLineNumber());
event.setCallerData(new StackTraceElement[] { callerData });
return event;
}