当前位置: 首页>>代码示例>>Java>>正文


Java LoggerContext.putProperty方法代码示例

本文整理汇总了Java中ch.qos.logback.classic.LoggerContext.putProperty方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerContext.putProperty方法的具体用法?Java LoggerContext.putProperty怎么用?Java LoggerContext.putProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.classic.LoggerContext的用法示例。


在下文中一共展示了LoggerContext.putProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beforeLogSystemInit

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
@Before
public void beforeLogSystemInit() throws IOException, InterruptedException {

    kafka = TestKafka.createTestKafka(1);

    loggerContext = new LoggerContext();
    loggerContext.putProperty("brokers.list", kafka.getBrokerList());
    loggerContext.getStatusManager().add(new StatusListener() {
        @Override
        public void addStatusEvent(Status status) {
            if (status.getEffectiveLevel() > Status.INFO) {
                System.err.println(status.toString());
                if (status.getThrowable() != null) {
                    collector.addError(status.getThrowable());
                } else {
                    collector.addError(new RuntimeException("StatusManager reported warning: "+status.toString()));
                }
            } else {
                System.out.println(status.toString());
            }
        }
    });
    loggerContext.putProperty("HOSTNAME","localhost");

    unit = new KafkaAppender<ILoggingEvent>();
    final PatternLayout patternLayout = new PatternLayout();
    patternLayout.setPattern("%msg");
    patternLayout.setContext(loggerContext);
    patternLayout.start();
    unit.setEncoder(new LayoutKafkaMessageEncoder(patternLayout, Charset.forName("UTF-8")));
    unit.setTopic("logs");
    unit.setName("TestKafkaAppender");
    unit.setContext(loggerContext);
    unit.addProducerConfigValue(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBrokerList());
    unit.setKeyingStrategy(new RoundRobinKeyingStrategy());
}
 
开发者ID:wngn123,项目名称:wngn-jms-kafka,代码行数:37,代码来源:KafkaAppenderIT.java

示例2: getLoggerContext

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
static LoggerContext getLoggerContext(
        final String[] keys,
        final String[] values) {
    // specifically cast to logback version so we can add advanced stuff (i.e. properties)
    final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.reset();
    for (int i = 0; i < keys.length; i++) {
        final String key = keys[i];
        final String value = values[i];
        if (!Strings.isNullOrEmpty(key) && !Strings.isNullOrEmpty(value)) {
            loggerContext.putProperty(key, value);
        }
    }
    return loggerContext;
}
 
开发者ID:secondbase,项目名称:secondbase,代码行数:16,代码来源:SecondBaseLogger.java


注:本文中的ch.qos.logback.classic.LoggerContext.putProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。