當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。