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


Java AppenderBase類代碼示例

本文整理匯總了Java中ch.qos.logback.core.AppenderBase的典型用法代碼示例。如果您正苦於以下問題:Java AppenderBase類的具體用法?Java AppenderBase怎麽用?Java AppenderBase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: initLogback

import ch.qos.logback.core.AppenderBase; //導入依賴的package包/類
public static void initLogback() {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    StatusManager statusManager = loggerContext.getStatusManager();
    if (statusManager != null) {
        statusManager.add(new InfoStatus("Setting up logger configuration.", loggerContext));
    }

    final PatternLayout layout = new PatternLayout();
    layout.setContext(loggerContext);
    layout.setPattern("%msg%n");
    layout.start();

    AppenderBase<ILoggingEvent> appender = new AppenderBase<ILoggingEvent>() {
        @Override
        protected void append(ILoggingEvent event) {
            String message = layout.doLayout(event);
            LogHelper.appendLogEntry(event.getTimeStamp(), convertLevel(event.getLevel()),
                    event.getLoggerName(), event.getThreadName(), message);
        }
    };
    appender.setContext(loggerContext);
    appender.setName(LOGBACK_APPENDER_NAME);
    appender.start();

    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.addAppender(appender);
}
 
開發者ID:noveogroup,項目名稱:clap,代碼行數:29,代碼來源:LogbackHelper.java

示例2: attachRootLogAppender

import ch.qos.logback.core.AppenderBase; //導入依賴的package包/類
private void attachRootLogAppender(final JTextArea textArea) {
    Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    ch.qos.logback.classic.Logger log = (ch.qos.logback.classic.Logger) rootLogger;
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    AppenderBase<ILoggingEvent> appender = new AppenderBase<ILoggingEvent>() {

        @Override
        protected void append(ILoggingEvent eventObject) {
            textArea.append(eventObject.getFormattedMessage() + System.lineSeparator());
        }
    };
    appender.setContext(context);
    appender.start();
    log.addAppender(appender);
    log.info("Applet log appender attached");
}
 
開發者ID:MovingBlocks,項目名稱:FacadeApplet,代碼行數:17,代碼來源:TerasologyApplet.java

示例3: doTest

import ch.qos.logback.core.AppenderBase; //導入依賴的package包/類
private void doTest(final Level level, final String msg, final String prefix) {
	Appender<ILoggingEvent> appender = new AppenderBase<ILoggingEvent>() {
		@Override
		protected void append(final ILoggingEvent eventObject) {
			assertEquals(eventObject.getFormattedMessage(), prefix != null ? prefix + msg : msg);
			assertEquals(eventObject.getLevel().toString(), level.name());
		}
	};

	LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
	lc.reset();
	appender.setContext(lc);
	appender.start();
	lc.getLogger(LoggingGobbleCallback.class).addAppender(appender);

	LoggingGobbleCallback callback = new LoggingGobbleCallback(level, prefix);
	callback.execute("foo");
}
 
開發者ID:mgm-tp,項目名稱:perfload-core,代碼行數:19,代碼來源:LoggingGobbleCallbackTest.java

示例4: setUp

import ch.qos.logback.core.AppenderBase; //導入依賴的package包/類
@Before
public void setUp() {
    LoggerContext ctx = (LoggerContext) LoggerFactory.getILoggerFactory();
    // any errors logged by dispatcher are actually assertion errors
    ctx.getLogger(Dispatcher.class.getName() + ".Counter").addAppender(new AppenderBase<ILoggingEvent>() {
        @Override
        protected void append(ILoggingEvent event) {
            if (event.getLevel() == Level.ERROR) {
                collector.addError(new AssertionError(event.getFormattedMessage()));
            }
        }
    });
    requestsMayFail = true;
    immediateRetries = true;
}
 
開發者ID:goodees,項目名稱:goodees,代碼行數:16,代碼來源:DispatcherTest.java

示例5: LogbackRecorder

import ch.qos.logback.core.AppenderBase; //導入依賴的package包/類
private LogbackRecorder(Logger logger) {
    this.logger = logger;
    this.events = new ArrayList<>();
    this.appender = new AppenderBase<ILoggingEvent>() {
        @Override
        protected synchronized void append(ILoggingEvent event) {
            events.add(new Event(event));
        }
    };
}
 
開發者ID:jhipster,項目名稱:jhipster,代碼行數:11,代碼來源:LogbackRecorder.java

示例6: addDefaultNestedComponentRegistryRules

import ch.qos.logback.core.AppenderBase; //導入依賴的package包/類
static public void addDefaultNestedComponentRegistryRules(
    DefaultNestedComponentRegistry registry) {
  registry.add(AppenderBase.class, "layout", PatternLayout.class);
  registry.add(UnsynchronizedAppenderBase.class, "layout", PatternLayout.class);
  
  registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class);
  registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class);
  
  registry
      .add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);

  SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:14,代碼來源:DefaultNestedComponentRules.java

示例7: addDefaultNestedComponentRegistryRules

import ch.qos.logback.core.AppenderBase; //導入依賴的package包/類
@Override
protected void addDefaultNestedComponentRegistryRules(
    DefaultNestedComponentRegistry registry) {
  registry.add(AppenderBase.class, "layout", PatternLayout.class);
        registry
      .add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);

  registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class);
  registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class);
  SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:12,代碼來源:JoranConfigurator.java


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