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


Java LoggingEvent.getLoggerName方法代码示例

本文整理汇总了Java中org.apache.log4j.spi.LoggingEvent.getLoggerName方法的典型用法代码示例。如果您正苦于以下问题:Java LoggingEvent.getLoggerName方法的具体用法?Java LoggingEvent.getLoggerName怎么用?Java LoggingEvent.getLoggerName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.spi.LoggingEvent的用法示例。


在下文中一共展示了LoggingEvent.getLoggerName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: append

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
protected void append(LoggingEvent event) {
	if (isDoLog(event.getLevel())) {
		String logString = layout.format(event);

		ILog myLog = getLog();
		if (myLog != null) {
			String loggerName = event.getLoggerName();
			int severity = mapLevel(event.getLevel());
			final Throwable throwable = event.getThrowableInformation() != null ? event.getThrowableInformation()
					.getThrowable() : null;
			IStatus status = createStatus(severity, loggerName, logString, throwable);
			getLog().log(status);
		} else {
			// nothing to do (message should be logged to stdout by default appender)
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:EclipseLogAppender.java

示例2: appendLoggerName

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
protected void appendLoggerName(LoggingEvent event, StringBuilder sbuf)
{
	String n = event.getLoggerName();
	int end = n.lastIndexOf('.', n.length() - 2);
	if( end >= 0 )
	{
		n = n.substring(end + 1);
	}
	sbuf.append(Transform.escapeTags(n));
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:HTMLLayout3.java

示例3: appendLoggerName

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
protected void appendLoggerName(LoggingEvent event, StringBuilder sbuf)
{
	String n = event.getLoggerName();
	int end = n.lastIndexOf('.', n.length() - 2);
	if( end >= 0 )
	{
		n = n.substring(end + 1);
	}
	sbuf.append(escapeForCsv(n));
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:CsvLayout1.java

示例4: 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


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