本文整理汇总了Java中org.apache.log4j.spi.LoggingEvent.getThreadName方法的典型用法代码示例。如果您正苦于以下问题:Java LoggingEvent.getThreadName方法的具体用法?Java LoggingEvent.getThreadName怎么用?Java LoggingEvent.getThreadName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.spi.LoggingEvent
的用法示例。
在下文中一共展示了LoggingEvent.getThreadName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: append
import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
protected void append(LoggingEvent event) {
if (this.useFastLocation) {
if (this.stackOffset < 0) this.stackOffset = FastLoggingEvent.getStackOffset(event);
event = new FastLoggingEvent(event, this.stackOffset);
}
if (this.storeLocation) event.getLocationInformation();
if (this.storeThreadName) event.getThreadName();
int position = -1;
synchronized (this) {
this.currentPosition = position = ++this.currentPosition % this.eventRing.length;
this.counter++;
} // SYNCH
this.eventRing[position] = event;
// assert(event.getLoggerName().contains("Handler") == false) : event;
}
示例2: append
import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
protected void append(LoggingEvent event) {
if (!event.getLevel().isGreaterOrEqual(getMinLevel())) return;
if (event.getLogger().equals(MessageLogAppender.class.getName())) return;
MessageLog m = new MessageLog();
m.setLevel(event.getLevel().toInt());
String logger = event.getLoggerName();
if (logger.indexOf('.') >= 0) logger = logger.substring(logger.lastIndexOf('.') + 1);
m.setLogger(logger.length() > 255 ? logger.substring(0, 255) : logger);
m.setMessage(event.getMessage() == null ? null : event.getMessage().toString());
m.setTimeStamp(new Date(event.getTimeStamp()));
m.setNdc(event.getNDC());
String thread = event.getThreadName();
m.setThread(thread == null ? null : thread.length() > 100 ? thread.substring(0, 100) : thread);
Throwable t = (event.getThrowableInformation() != null ? event.getThrowableInformation().getThrowable() : null);
if (t != null) {
String ex = "";
while (t != null) {
String clazz = t.getClass().getName();
if (clazz.indexOf('.') >= 0) clazz = clazz.substring(1 + clazz.lastIndexOf('.'));
if (!ex.isEmpty()) ex += "\n";
ex += clazz + ": " + t.getMessage();
if (t.getStackTrace() != null && t.getStackTrace().length > 0)
ex += " (at " + t.getStackTrace()[0].getFileName() + ":" + t.getStackTrace()[0].getLineNumber() + ")";
t = t.getCause();
}
if (!ex.isEmpty())
m.setException(ex);
}
getSaver().add(m);
}
示例3: defaultLogFormat
import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
static private Object defaultLogFormat(LoggingEvent loggingEvent) {
LoggingEventX eventX = new LoggingEventX(loggingEvent.getFQNOfLoggerClass(), loggingEvent.getLogger()
, loggingEvent.getTimeStamp(), loggingEvent.getLevel(), loggingEvent.getMessage(),
loggingEvent.getThreadName(), loggingEvent.getThrowableInformation(), loggingEvent.getNDC(),
loggingEvent.getLocationInformation(), loggingEvent.getProperties());
eventX.setLogTime(new Date(loggingEvent.getTimeStamp()));
eventX.setLogLevel(eventX.getLevel().toString());
return eventX;
}