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


Java LocationInfo.getFileName方法代码示例

本文整理汇总了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";
}
 
开发者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: 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();
  }
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:15,代码来源:SpectatorAppender.java

示例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;
	}
}
 
开发者ID:OurGrid,项目名称:commune,代码行数:16,代码来源:SyncPatternParser.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.getFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。