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


Java LocationInfo.getMethodName方法代码示例

本文整理汇总了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";
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:39,代码来源:BenderLayout.java

示例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;
     }
   }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:16,代码来源:PatternParser.java

示例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;
	}
}
 
开发者ID:OurGrid,项目名称:commune,代码行数:16,代码来源:SyncPatternParser.java

示例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();
}
 
开发者ID:stackify,项目名称:stackify-log-log4j12,代码行数:49,代码来源:LoggingEventAdapter.java

示例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;
}
 
开发者ID:szhem,项目名称:log4j-json-layout,代码行数:48,代码来源:LogStashJsonLayout.java


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