当前位置: 首页>>代码示例>>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;未经允许,请勿转载。