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


Java StatusConsoleListener類代碼示例

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


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

示例1: setupQueue

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
private static void setupQueue() throws Exception {
    // MockContextFactory becomes the primary JNDI provider
    final StatusConsoleListener l = new StatusConsoleListener(Level.ERROR);
    StatusLogger.getLogger().registerListener(l);
    MockContextFactory.setAsInitial();
    context = new InitialContext();
    context.rebind(FACTORY_NAME, new QueueConnectionFactoryImpl() );
    //context.rebind(QUEUE_NAME, new MockQueue(QUEUE_NAME));
    //System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
    //receiver = new JMSQueueReceiver(FACTORY_NAME, QUEUE_NAME, null, null);
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:12,代碼來源:JMSQueueFailoverTest.java

示例2: setupClass

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
@BeforeClass
public static void setupClass() throws Exception {
    // MockContextFactory becomes the primary JNDI provider
    final StatusConsoleListener l = new StatusConsoleListener(Level.ERROR);
    StatusLogger.getLogger().registerListener(l);
    MockContextFactory.setAsInitial();
    context = new InitialContext();
    context.rebind(FACTORY_NAME, new QueueConnectionFactoryImpl() );
    context.rebind(QUEUE_NAME, new MockQueue(QUEUE_NAME));
    ((LoggerContext) LogManager.getContext()).reconfigure();
    receiver = new JMSQueueReceiver(FACTORY_NAME, QUEUE_NAME, null, null);
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:13,代碼來源:JMSQueueTest.java

示例3: setupClass

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
@BeforeClass
public static void setupClass() throws Exception {
    // MockContextFactory becomes the primary JNDI provider
    final StatusConsoleListener l = new StatusConsoleListener(Level.ERROR);
    StatusLogger.getLogger().registerListener(l);
    MockContextFactory.setAsInitial();
    context = new InitialContext();
    context.rebind(FACTORY_NAME, new TopicConnectionFactoryImpl() );
    context.rebind(TOPIC_NAME, new MockTopic(TOPIC_NAME) );
    ((LoggerContext) LogManager.getContext()).reconfigure();
    receiver = new JMSTopicReceiver(FACTORY_NAME, TOPIC_NAME, null, null);
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:13,代碼來源:JMSTopicTest.java

示例4: setupClass

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
@BeforeClass
public static void setupClass() throws Exception {
    // MockContextFactory becomes the primary JNDI provider
    final StatusConsoleListener l = new StatusConsoleListener(Level.ERROR);
    StatusLogger.getLogger().registerListener(l);
    MockContextFactory.setAsInitial();
    context = new InitialContext();
    context.rebind(FACTORY_NAME, new QueueConnectionFactoryImpl() );
    context.rebind(QUEUE_NAME, new MockQueue(QUEUE_NAME));
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
    receiver = new JMSQueueReceiver(FACTORY_NAME, QUEUE_NAME, null, null);
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:13,代碼來源:JMSQueueAppenderTest.java

示例5: setupQueue

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
private static void setupQueue() throws Exception {
    // MockContextFactory becomes the primary JNDI provider
    final StatusConsoleListener l = new StatusConsoleListener(Level.ERROR);
    StatusLogger.getLogger().registerListener(l);
    MockContextFactory.setAsInitial();
    context = new InitialContext();
    context.rebind(FACTORY_NAME, new TopicConnectionFactoryImpl() );
    //context.rebind(QUEUE_NAME, new MockQueue(QUEUE_NAME));
    //System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
    //receiver = new JMSQueueReceiver(FACTORY_NAME, QUEUE_NAME, null, null);
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:12,代碼來源:JMSTopicFailoverTest.java

示例6: configureExistingStatusConsoleListener

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
private boolean configureExistingStatusConsoleListener() {
    boolean configured = false;
    for (final StatusListener statusListener : this.logger.getListeners()) {
        if (statusListener instanceof StatusConsoleListener) {
            final StatusConsoleListener listener = (StatusConsoleListener) statusListener;
            listener.setLevel(this.status);
            this.logger.updateListenerLevel(this.status);
            if (this.verbosity == Verbosity.QUIET) {
                listener.setFilters(this.verboseClasses);
            }
            configured = true;
        }
    }
    return configured;
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:16,代碼來源:StatusConfiguration.java

示例7: registerNewStatusConsoleListener

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
private void registerNewStatusConsoleListener() {
    final StatusConsoleListener listener = new StatusConsoleListener(this.status, this.destination);
    if (this.verbosity == Verbosity.QUIET) {
        listener.setFilters(this.verboseClasses);
    }
    this.logger.registerListener(listener);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:8,代碼來源:StatusConfiguration.java

示例8: testConfig

import org.apache.logging.log4j.status.StatusConsoleListener; //導入依賴的package包/類
@Test
public void testConfig() {
    // don't bother using "error" since that's the default; try another level
    final LoggerContext ctx = this.init.getLoggerContext();
    ctx.reconfigure();
    final Configuration config = ctx.getConfiguration();
    assertThat(config, instanceOf(XmlConfiguration.class));
    for (final StatusListener listener : StatusLogger.getLogger().getListeners()) {
        if (listener instanceof StatusConsoleListener) {
            assertSame(listener.getStatusLevel(), Level.INFO);
            break;
        }
    }
    final Layout<? extends Serializable> layout = PatternLayout.newBuilder()
        .withPattern(PatternLayout.SIMPLE_CONVERSION_PATTERN)
        .withConfiguration(config)
        .build();
    // @formatter:off
    final FileAppender appender = FileAppender.newBuilder()
        .withFileName(LOG_FILE)
        .withAppend(false)
        .withName("File")
        .withIgnoreExceptions(false)
        .withBufferSize(4000)
        .withBufferedIo(false)
        .withLayout(layout)
        .build();
    // @formatter:on
    appender.start();
    config.addAppender(appender);
    final AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
    final AppenderRef[] refs = new AppenderRef[] {ref};

    final LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.INFO, "org.apache.logging.log4j",
        "true", refs, null, config, null );
    loggerConfig.addAppender(appender, null, null);
    config.addLogger("org.apache.logging.log4j", loggerConfig);
    ctx.updateLoggers();
    final Logger logger = ctx.getLogger(CustomConfigurationTest.class.getName());
    logger.info("This is a test");
    final File file = new File(LOG_FILE);
    assertThat(file, exists());
    assertThat(file, hasLength(greaterThan(0L)));
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:45,代碼來源:CustomConfigurationTest.java


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