当前位置: 首页>>代码示例>>Java>>正文


Java LoggingEvent.getThreadName方法代码示例

本文整理汇总了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;
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:18,代码来源:RingBufferAppender.java

示例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);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:40,代码来源:MessageLogAppender.java

示例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;
    }
 
开发者ID:Crab2died,项目名称:log4j-redis-appender,代码行数:12,代码来源:RedisAppender.java


注:本文中的org.apache.log4j.spi.LoggingEvent.getThreadName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。