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


Java LoggingEvent.setThrowableProxy方法代码示例

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


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

示例1: makeEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private LoggingEvent makeEvent(Level level, String message, Throwable th) {
	LoggingEvent event = new LoggingEvent();
	event.setLoggerName(CloudWatchAppender.class.getName());
	event.setLevel(level);
	event.setMessage(message);
	event.setTimeStamp(System.currentTimeMillis());
	if (th != null) {
		event.setThrowableProxy(new ThrowableProxy(th));
	}
	return event;
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:12,代码来源:CloudWatchAppender.java

示例2: onLog

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
public void onLog(LogEntry logEntry) {

  final LoggingEvent loggingEvent = new LoggingEvent();
  loggingEvent.setTimeStamp(logEntry.getTimestamp());
  loggingEvent.setLoggerName(logEntry.getLoggerName());
  loggingEvent.setLevel(Level.valueOf(logEntry.getLogLevel().name()));
  loggingEvent.setThreadName(logEntry.getThreadName());
  Object [] formatObjects = new Object[] {logEntry.getHost(),
    getSimpleClassName(logEntry.getSourceClassName()),
    logEntry.getSourceMethodName(),
    logEntry.getFileName(),
    logEntry.getLineNumber(),logEntry.getMessage()};
  loggingEvent.setMessage(MESSAGE_FORMAT.get().format(formatObjects));

  // Prints the throwable and stack trace.
  LogThrowable logThrowable = logEntry.getThrowable();
  if (logThrowable != null) {
    loggingEvent.setThrowableProxy(new ThrowableProxy(setThrowable(logThrowable)));
  }

  if (logger instanceof Logger) {
    ((Logger) logger).callAppenders(loggingEvent);
  } else {
    logger.info("Logger is not instance of ch.qos.logback.classic.Logger. Logger event is: {}", loggingEvent);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:YarnTwillLogHandler.java

示例3: layoutWithException

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void layoutWithException() throws Exception {
  layout.setPattern("%level %thread %msg %ex");
  LoggingEvent le = createLoggingEvent();
  le.setThrowableProxy(new ThrowableProxy(new Exception("test Exception")));
  String result = layout.doLayout(le);

  String stringToParse = layout.getFileHeader();
  stringToParse = stringToParse + layout.getPresentationHeader();
  stringToParse += result;
  stringToParse += "</table></body></html>";

  // System.out.println(stringToParse);

  Document doc = parseOutput(stringToParse);
  Element rootElement = doc.getRootElement();
  Element bodyElement = rootElement.element("body");
  Element tableElement = bodyElement.element("table");
  List<Element> trElementList = tableElement.elements();
  Element exceptionRowElement = trElementList.get(2);
  Element exceptionElement = exceptionRowElement.element("td");

  assertEquals(3, tableElement.elements().size());
  assertTrue(exceptionElement.getText().contains(
      "java.lang.Exception: test Exception"));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:28,代码来源:HTMLLayoutTest.java


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