本文整理汇总了Java中org.apache.log4j.spi.LocationInfo.getFileName方法的典型用法代码示例。如果您正苦于以下问题:Java LocationInfo.getFileName方法的具体用法?Java LocationInfo.getFileName怎么用?Java LocationInfo.getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.spi.LocationInfo
的用法示例。
在下文中一共展示了LocationInfo.getFileName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import org.apache.log4j.spi.LocationInfo; //导入方法依赖的package包/类
@Override
public String format(LoggingEvent event) {
BenderLogEntry entry = new BenderLogEntry();
entry.threadName = event.getThreadName();
entry.posixTimestamp = event.getTimeStamp();
entry.timestamp = FORMATTER.print(entry.posixTimestamp);
entry.message = event.getRenderedMessage();
entry.level = event.getLevel().toString();
entry.logger = event.getLogger().getName();
entry.alias = ALIAS;
entry.version = VERSION;
if (event.getThrowableInformation() != null) {
final ThrowableInformation throwableInfo = event.getThrowableInformation();
ExceptionLog ex = new ExceptionLog();
if (throwableInfo.getThrowable().getClass().getCanonicalName() != null) {
ex.clazz = throwableInfo.getThrowable().getClass().getCanonicalName();
}
if (throwableInfo.getThrowable().getMessage() != null) {
ex.message = throwableInfo.getThrowable().getMessage();
}
if (throwableInfo.getThrowableStrRep() != null) {
Arrays.asList(throwableInfo.getThrowableStrRep()).forEach(m -> {
ex.stacktrace.add(m.replaceAll("\\t", " "));
});
}
entry.exception = ex;
}
LocationInfo locinfo = event.getLocationInformation();
entry.file = locinfo.getFileName();
entry.lineNumber = Integer.parseInt(locinfo.getLineNumber());
entry.method = locinfo.getMethodName();
entry.clazz = locinfo.getClassName();
return GSON.toJson(entry) + "\n";
}
示例2: convert
import org.apache.log4j.spi.LocationInfo; //导入方法依赖的package包/类
public
String convert(LoggingEvent event) {
LocationInfo locationInfo = event.getLocationInformation();
switch(type) {
case FULL_LOCATION_CONVERTER:
return locationInfo.fullInfo;
case METHOD_LOCATION_CONVERTER:
return locationInfo.getMethodName();
case LINE_LOCATION_CONVERTER:
return locationInfo.getLineNumber();
case FILE_LOCATION_CONVERTER:
return locationInfo.getFileName();
default: return null;
}
}
示例3: append
import org.apache.log4j.spi.LocationInfo; //导入方法依赖的package包/类
@Override protected void append(LoggingEvent event) {
final LevelTag level = LevelTag.get(event.getLevel());
registry.counter(numMessages[level.ordinal()]).increment();
ThrowableInformation info = event.getThrowableInformation();
if (info != null) {
LocationInfo loc = event.getLocationInformation();
final String file = (loc == null) ? "unknown" : loc.getFileName();
Id stackTraceId = numStackTraces[level.ordinal()]
.withTag("exception", info.getThrowable().getClass().getSimpleName())
.withTag("file", file);
registry.counter(stackTraceId).increment();
}
}
示例4: convert
import org.apache.log4j.spi.LocationInfo; //导入方法依赖的package包/类
public
String convert(LoggingEvent event) {
LocationInfo locationInfo = event.getLocationInformation();
switch(type) {
case FULL_LOCATION_CONVERTER:
return locationInfo.fullInfo;
case METHOD_LOCATION_CONVERTER:
return locationInfo.getMethodName();
case LINE_LOCATION_CONVERTER:
return locationInfo.getLineNumber();
case FILE_LOCATION_CONVERTER:
return locationInfo.getFileName();
default: return null;
}
}
示例5: appendLocation
import org.apache.log4j.spi.LocationInfo; //导入方法依赖的package包/类
private boolean appendLocation(StringBuilder buf, LoggingEvent event) {
LocationInfo locationInfo = event.getLocationInformation();
if (locationInfo == null) {
return false;
}
boolean hasPrevField = false;
appendQuotedName(buf, Field.LOCATION.val);
buf.append(":{");
String className = locationInfo.getClassName();
if (className != null) {
appendField(buf, LocationField.CLASS.val, className);
hasPrevField = true;
}
String fileName = locationInfo.getFileName();
if (fileName != null) {
if (hasPrevField) {
buf.append(',');
}
appendField(buf, LocationField.FILE.val, fileName);
hasPrevField = true;
}
String methodName = locationInfo.getMethodName();
if (methodName != null) {
if (hasPrevField) {
buf.append(',');
}
appendField(buf, LocationField.METHOD.val, methodName);
hasPrevField = true;
}
String lineNum = locationInfo.getLineNumber();
if (lineNum != null) {
if (hasPrevField) {
buf.append(',');
}
appendField(buf, LocationField.LINE.val, lineNum);
}
buf.append('}');
return true;
}