本文整理汇总了Java中org.apache.log4j.spi.LocationInfo.getMethodName方法的典型用法代码示例。如果您正苦于以下问题:Java LocationInfo.getMethodName方法的具体用法?Java LocationInfo.getMethodName怎么用?Java LocationInfo.getMethodName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.spi.LocationInfo
的用法示例。
在下文中一共展示了LocationInfo.getMethodName方法的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: 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;
}
}
示例4: getStackifyError
import org.apache.log4j.spi.LocationInfo; //导入方法依赖的package包/类
/**
* @see com.stackify.api.common.log.EventAdapter#getStackifyError(java.lang.Object, java.lang.Throwable)
*/
@Override
public StackifyError getStackifyError(final LoggingEvent event, final Throwable exception) {
StackifyError.Builder builder = StackifyError.newBuilder();
builder.environmentDetail(envDetail);
builder.occurredEpochMillis(new Date(event.getTimeStamp()));
if (exception != null) {
builder.error(Throwables.toErrorItem(getMessage(event), exception));
} else {
String className = null;
String methodName = null;
int lineNumber = 0;
LocationInfo locInfo = event.getLocationInformation();
if (locInfo != null) {
className = locInfo.getClassName();
methodName = locInfo.getMethodName();
try {
lineNumber = Integer.parseInt(locInfo.getLineNumber());
} catch (Throwable e) {
}
}
builder.error(Throwables.toErrorItem(getMessage(event), className, methodName, lineNumber));
}
String user = APMLogData.isLinked() ? APMLogData.getUser() : ServletLogContext.getUser();
if (user != null) {
builder.userName(user);
}
WebRequestDetail webRequest = APMLogData.isLinked() ? APMLogData.getWebRequest() : ServletLogContext.getWebRequest();
if (webRequest != null) {
builder.webRequestDetail(webRequest);
}
builder.serverVariables(Maps.fromProperties(System.getProperties()));
return builder.build();
}
示例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;
}