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


Java LoggingEvent.setCallerData方法代码示例

本文整理汇总了Java中ch.qos.logback.classic.spi.LoggingEvent.setCallerData方法的典型用法代码示例。如果您正苦于以下问题:Java LoggingEvent.setCallerData方法的具体用法?Java LoggingEvent.setCallerData怎么用?Java LoggingEvent.setCallerData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.classic.spi.LoggingEvent的用法示例。


在下文中一共展示了LoggingEvent.setCallerData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTranslate

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void testTranslate() throws Exception {
  //Given
  LoggerContext context = new LoggerContext();
  Logger logger = context.getLogger("SomeLogger");
  LoggingEvent le = new LoggingEvent("a.b.C",logger, ch.qos.logback.classic.Level.INFO,"message",null,null);
  final Map<String, String> split = Splitter.on(",").withKeyValueSeparator("=").split("a=b,b=as");
  le.setMDCPropertyMap(split);
  le.setCallerData(new StackTraceElement[]{new StackTraceElement("a.b.C","someMethod","C.java",120)});

  //when
  final LogData logData = LogbackUtil.translate(le).build();

  //then
  assertEquals(logData.getMessage(),"message");
  assertEquals(logData.getLevel(),Level.INFO);
  assertEquals(logData.getLoggerName(),"SomeLogger");
  assertEquals(logData.getClazz(),"a.b.C");
  assertEquals(logData.getMethod(),"someMethod");
  assertEquals(logData.getLine(),"120");
  assertEquals(logData.getProperties(),split);
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:23,代码来源:LogbackUtilTest.java

示例2: logEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private static void logEvent(Ehcache cache, Element elem, CacheEventType eventType) {
    int cacheApproxSize = -1;

    if (cache.getStatus() == Status.STATUS_ALIVE) {
        try {
            cacheApproxSize = cache.getSize();
        } catch (CacheException | IllegalStateException ignored) {
        }
    }

    LoggingEvent loggingEvent = new LoggingEvent(Logger.FQCN, LOGGER, Level.TRACE,
        String.format(MSG_FORMAT, cache.getName(), cache.getStatus(), cacheApproxSize, elem.getObjectKey(), eventType.getId()), null, null);
    StackTraceElement[] stackFrames = new Throwable().getStackTrace();

    for (int a = 1; a < stackFrames.length; a++) {
        if (!STACK_SKIP_CLASS_NAMES.contains(stackFrames[a].getClassName())) {
            stackFrames = ArrayUtils.subarray(stackFrames, a, stackFrames.length);

            break;
        }
    }

    loggingEvent.setCallerData(stackFrames);

    LOGGER.callAppenders(loggingEvent);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:27,代码来源:LoggingCacheListener.java

示例3: report

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
public void report(SdcctIssueSeverity severity, String msg, SdcctLocation loc, @Nullable Throwable cause) {
    LoggingEvent event = new LoggingEvent(Logger.FQCN, LOGGER, SEVERITY_LEVELS.get(severity), msg, cause, null);
    StackTraceElement[] stackFrames = new Throwable().getStackTrace();

    for (int a = 1; a < stackFrames.length; a++) {
        if (!STACK_SKIP_CLASS_NAMES.contains(stackFrames[a].getClassName())) {
            stackFrames = ArrayUtils.subarray(stackFrames, a, stackFrames.length);

            break;
        }
    }

    event.setCallerData(stackFrames);

    LOGGER.callAppenders(event);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:18,代码来源:LoggingXmlReporter.java

示例4: log

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
public void log(Level level, @Nullable String msg, @Nullable Throwable cause) {
    LoggingEvent event = new LoggingEvent(ch.qos.logback.classic.Logger.FQCN, LOGGER, level, msg, cause, null);

    StackTraceElement[] stackFrames = new Throwable().getStackTrace();

    for (int a = 1; a < stackFrames.length; a++) {
        if (!STACK_SKIP_CLASS_NAMES.contains(stackFrames[a].getClassName())) {
            stackFrames = ArrayUtils.subarray(stackFrames, a, stackFrames.length);

            break;
        }
    }

    event.setCallerData(stackFrames);

    LOGGER.callAppenders(event);
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:18,代码来源:CrigttLogger.java

示例5: createLoggingEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private LoggingEvent createLoggingEvent() {
  LoggingEvent event = new LoggingEvent("com.example.XMLLayoutTest-<&>'\"]]>", root,
  Level.DEBUG, MESSAGE,
  new RuntimeException("Dummy exception: <&>'\"]]>"), null);
  event.setThreadName("Dummy thread <&>'\"");
  event.getMDCPropertyMap().put(MDC_KEY, MDC_VALUE);

  StackTraceElement ste1 = new StackTraceElement("c1", "m1", "f1", 1);
  StackTraceElement ste2 = new StackTraceElement("c2", "m2", "f2", 2);
  event.setCallerData(new StackTraceElement[]{ ste1, ste2} );

  return event;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:14,代码来源:XMLLayoutTest.java

示例6: emptyCallerDataShouldBeHandledGracefully

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void emptyCallerDataShouldBeHandledGracefully() {
  LoggingEvent event = createLoggingEvent();
  event.setCallerData(new StackTraceElement[0]);
  appender.append(event);

  event.setCallerData(new StackTraceElement[] {null});
  appender.append(event);

  checker.assertIsErrorFree();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:12,代码来源:DBAppenderH2Test.java

示例7: newEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
protected Object newEvent(LogDetails logDetails) {
    ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logDetails.getClassName());
    LoggingEvent event = new LoggingEvent(this.getClass().getName(), logger, Level.DEBUG, logDetails.getLogMessage(),
            logDetails.getException(), null);
    event.setThreadName(logDetails.getThreadName());
    event.setTimeStamp(logDetails.getTimeMillis());
    event.setMDCPropertyMap(logDetails.getMdc());
    StackTraceElement callerData = new StackTraceElement(logDetails.getClassName(), logDetails.getMethodName(),
            logDetails.getFileName(), logDetails.getLineNumber());
    event.setCallerData(new StackTraceElement[] { callerData });
    return event;
}
 
开发者ID:Talend,项目名称:daikon,代码行数:14,代码来源:LogBackJSONLayoutTest.java


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