本文整理匯總了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;
}