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


Java Logger.info方法代碼示例

本文整理匯總了Java中org.apache.logging.log4j.core.Logger.info方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.info方法的具體用法?Java Logger.info怎麽用?Java Logger.info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.logging.log4j.core.Logger的用法示例。


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

示例1: testAfterSetProperties

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
@Test
public void testAfterSetProperties() throws Exception {

    System.setProperty(PROPERTY1, PROPERTY1_VALUE);
    System.setProperty(PROPERTY2, PROPERTY2_VALUE);

    setup();
    Logger logger = loggerContext.getLogger(getClass().getName());

    logger.info(LOG_MESSAGE);
    assertThat(GelfTestSender.getMessages()).hasSize(1);

    GelfMessage gelfMessage = GelfTestSender.getMessages().get(0);

    assertThat(gelfMessage.getField("propertyField1")).isEqualTo(System.getProperty("user.language"));
    assertThat(gelfMessage.getField("propertyField2")).isEqualTo(PROPERTY1_VALUE);
    assertThat(gelfMessage.getField("propertyField3")).isEqualTo("${sys:otherproperty:fallback}");
    assertThat(gelfMessage.getField("propertyField4")).isEqualTo("embedded" + PROPERTY1_VALUE + "property");
}
 
開發者ID:mp911de,項目名稱:logstash-gelf,代碼行數:20,代碼來源:GelfLogAppenderSystemPropertiesTests.java

示例2: testClientServer

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
@Test(timeout = DEFAULT_TIMEOUT_MILLIS)
public void testClientServer() throws Exception {
    final JeroMqAppender appender = ctx.getRequiredAppender(APPENDER_NAME, JeroMqAppender.class);
    final int expectedReceiveCount = 3;
    final JeroMqTestClient client = new JeroMqTestClient(JeroMqManager.getContext(), ENDPOINT, expectedReceiveCount);
    final ExecutorService executor = Executors.newSingleThreadExecutor();
    try {
        final Future<List<String>> future = executor.submit(client);
        Thread.sleep(100);
        final Logger logger = ctx.getLogger(getClass().getName());
        appender.resetSendRcs();
        logger.info("Hello");
        logger.info("Again");
        ThreadContext.put("foo", "bar");
        logger.info("World");
        final List<String> list = future.get();
        Assert.assertEquals(expectedReceiveCount, appender.getSendRcTrue());
        Assert.assertEquals(0, appender.getSendRcFalse());
        Assert.assertEquals("Hello", list.get(0));
        Assert.assertEquals("Again", list.get(1));
        Assert.assertEquals("barWorld", list.get(2));
    } finally {
        executor.shutdown();
    }
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:26,代碼來源:JeroMqAppenderTest.java

示例3: testDefaults

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
@Test
public void testDefaults() throws Exception {

    Logger logger = loggerContext.getLogger(getClass().getName());

    logger.info(LOG_MESSAGE);
    assertThat(GelfTestSender.getMessages()).hasSize(1);

    GelfMessage gelfMessage = GelfTestSender.getMessages().get(0);

    assertThat(gelfMessage.getField("propertyField1")).isEqualTo(System.getProperty("user.language"));
    assertThat(gelfMessage.getField("propertyField2")).isEqualTo("${sys:myproperty}");
    assertThat(gelfMessage.getField("propertyField3")).isEqualTo("${sys:otherproperty:fallback}");
    assertThat(gelfMessage.getField("propertyField4")).isEqualTo("embedded${sys:myproperty}property");
}
 
開發者ID:mp911de,項目名稱:logstash-gelf,代碼行數:16,代碼來源:GelfLogAppenderSystemPropertiesTests.java

示例4: testServerOnly

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
@Test(timeout = DEFAULT_TIMEOUT_MILLIS)
public void testServerOnly() throws Exception {
    final Logger logger = ctx.getLogger(getClass().getName());
    final JeroMqAppender appender = ctx.getRequiredAppender(APPENDER_NAME, JeroMqAppender.class);
    appender.resetSendRcs();
    logger.info("Hello");
    logger.info("Again");
    Assert.assertEquals(2, appender.getSendRcTrue());
    Assert.assertEquals(0, appender.getSendRcFalse());
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:11,代碼來源:JeroMqAppenderTest.java

示例5: append

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
private static void append(Logger logger, String message) {
    LOGGER.debug("trying to append: %s", message);
    logger.info(message);
}
 
開發者ID:vy,項目名稱:log4j2-redis-appender,代碼行數:5,代碼來源:RedisAppenderReconnectTest.java


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