本文整理汇总了Java中org.apache.log4j.spi.LocationInfo.getLineNumber方法的典型用法代码示例。如果您正苦于以下问题:Java LocationInfo.getLineNumber方法的具体用法?Java LocationInfo.getLineNumber怎么用?Java LocationInfo.getLineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.spi.LocationInfo
的用法示例。
在下文中一共展示了LocationInfo.getLineNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例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: 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;
}