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