本文整理汇总了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)
}
}
}
示例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));
}
示例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));
}
示例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);
}