當前位置: 首頁>>代碼示例>>Java>>正文


Java Logger.detachAppender方法代碼示例

本文整理匯總了Java中ch.qos.logback.classic.Logger.detachAppender方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.detachAppender方法的具體用法?Java Logger.detachAppender怎麽用?Java Logger.detachAppender使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.classic.Logger的用法示例。


在下文中一共展示了Logger.detachAppender方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: apply

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
@Override
public Statement apply(Statement base, FrameworkMethod method, Object target) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      logAppender = new StubAppender();
      Logger root = (Logger) LoggerFactory.getLogger(loggerName);

      root.addAppender(logAppender);
      try {
        base.evaluate();
      } finally {
        root.detachAppender(logAppender);
      }
    }
  };
}
 
開發者ID:mustaine,項目名稱:logcapture,代碼行數:18,代碼來源:LogCaptureRule.java

示例2: configureInMemoryLogging

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
private static void configureInMemoryLogging() {
    org.slf4j.Logger rootLogger = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    Logger logbackRootLogger = (Logger) rootLogger;
    logbackRootLogger.setLevel(Level.INFO);

    OutputStreamAppender<ILoggingEvent> appender = new OutputStreamAppender<>();
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    PatternLayoutEncoder ple = new PatternLayoutEncoder();
    ple.setPattern("[%date] [%level] [%logger{10}] %msg%n");
    ple.setContext(lc);
    ple.start();
    try {
        ple.init(bos);
    } catch (IOException e) {
    }
    appender.setContext(lc);
    appender.setOutputStream(bos);
    appender.setName("buffered");
    appender.setEncoder(ple);
    appender.start();

    logbackRootLogger.detachAppender("console");
    logbackRootLogger.addAppender(appender);
    logbackRootLogger.setAdditive(true);
}
 
開發者ID:spinscale,項目名稱:maxcube-java,代碼行數:26,代碼來源:Cli.java

示例3: captureLogEvents

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
public static <T> LogCapture<T> captureLogEvents(Supplier<T> codeBlock, String loggerName) {
  StubAppender logAppender = new StubAppender();
  Logger root = (Logger) LoggerFactory.getLogger(loggerName);

  root.addAppender(logAppender);
  try {
    T result = codeBlock.get();
    return new LogCapture<>(logAppender.events(), result);
  } finally {
    root.detachAppender(logAppender);
  }
}
 
開發者ID:mustaine,項目名稱:logcapture,代碼行數:13,代碼來源:LogbackInterceptor.java

示例4: captureLogEventsAsync

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
public static <T> LogCapture<T> captureLogEventsAsync(Supplier<T> codeBlock, Duration duration, ExpectedLoggingMessage expectedLoggingMessage) {
  StubAppender logAppender = new StubAppender();
  Logger root = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME);

  root.addAppender(logAppender);
  try {
    T result = codeBlock.get();
    awaitForLogMessage(duration, hasLoggedMessage(logAppender.events(), expectedLoggingMessage));
    return new LogCapture<>(logAppender.events(), result);
  } finally {
    root.detachAppender(logAppender);
  }
}
 
開發者ID:mustaine,項目名稱:logcapture,代碼行數:14,代碼來源:LogbackInterceptor.java

示例5: tearDown

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
@After
public void tearDown() throws Exception {
    final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    logger.detachAppender(mockAppender);
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:6,代碼來源:NotOnOrAfterLoggerTest.java

示例6: detachDefaultConsoleAppender

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
private void detachDefaultConsoleAppender() {
    Logger rootLogger = getRootLogger();
    Appender<ILoggingEvent> consoleAppender = rootLogger.getAppender("console");
    rootLogger.detachAppender(consoleAppender);
}
 
開發者ID:warlock-china,項目名稱:wisp,代碼行數:6,代碼來源:LogbackCapturingAppender.java


注:本文中的ch.qos.logback.classic.Logger.detachAppender方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。