org.apache.logging.log4j.core.Logger.info()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中org.apache.logging.log4j.core.Logger.info()方法的一些代码示例,展示了Logger.info()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.info()方法的具体详情如下:
包路径:org.apache.logging.log4j.core.Logger
类名称:Logger
方法名:info

Logger.info介绍

暂无

代码示例

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Override
  public void run() {
    logger.info("Hello");
    logger.info("Again");
  }
});

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public void info(@Nullable String marker, String msg) {
  if (!isInfoEnabled())
    warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
  impl.info(getMarkerOrNull(marker), msg);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testDateLookupInMessage() {
  final String template = "${date:YYYY-MM-dd}";
  context.getLogger(PatternLayoutNoLookupDateTest.class.getName()).info(template);
  final ListAppender listAppender = context.getListAppender("List");
  final String string = listAppender.getMessages().get(0);
  Assert.assertTrue(string, string.contains(template));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testDateLookupInMessage() {
  final String template = "${date:YYYY-MM-dd}";
  context.getLogger(PatternLayoutLookupDateTest.class.getName()).info(template);
  final ListAppender listAppender = context.getListAppender("List");
  final String string = listAppender.getMessages().get(0);
  Assert.assertFalse(string, string.contains(template));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@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());
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@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();
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

protected void sendInfoStructuredMessage() {
  ThreadContext.put("loginId", "JohnDoe");
  ThreadContext.put("ipAddress", "192.168.0.120");
  ThreadContext.put("locale", Locale.US.getDisplayName());
  final StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
  msg.put("ToAccount", "123456");
  msg.put("FromAccount", "123457");
  msg.put("Amount", "200.00");
  // the msg.toString() doesn't contain the parameters of the ThreadContext, so we must use the line1 string
  final String str = msg.asString(null, null);
  sentMessages.add(str);
  root.info(MarkerManager.getMarker("EVENT"), msg);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testSubstituteStructuredData() {
  final String mdcId = "RequestContext";
  final String expectedToContain = String.format("ATM %s MSG-ID - Message", PROCESSID);
  for (final Appender appender : root.getAppenders().values()) {
    root.removeAppender(appender);
  }
  final AbstractStringLayout layout = Rfc5424Layout.createLayout(Facility.LOCAL0, "Event", 3692, false, mdcId,
      null, null, true, null, "ATM", "MSG-ID", "key1, key2, locale", null, null, null, false, null, null);
  final ListAppender appender = new ListAppender("List", null, layout, true, false);
  appender.start();
  root.addAppender(appender);
  root.setLevel(Level.DEBUG);
  root.info("Message");
  try {
    final List<String> list = appender.getMessages();
    assertTrue("Not enough list entries", list.size() > 0);
    final String message =  list.get(0);
    Assert.assertTrue("Not the expected message received", message.contains(expectedToContain));
    appender.clear();
  } finally {
    root.removeAppender(appender);
    appender.stop();
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
  public void testParameterizedMessage() {
    for (final Appender appender : root.getAppenders().values()) {
      root.removeAppender(appender);
    }
    // set up appender
    final AbstractStringLayout layout = Rfc5424Layout.createLayout(Facility.LOCAL0, "Event", 3692, true, "RequestContext",
      null, null, true, null, "ATM", null, "key1, key2, locale", null, null, null, true, null, null);
    final ListAppender appender = new ListAppender("List", null, layout, true, false);

    appender.start();

    // set appender on root and set level to debug
    root.addAppender(appender);
    root.setLevel(Level.DEBUG);
    root.info("Hello {}", "World");
    try {
      final List<String> list = appender.getMessages();
      assertTrue("Not enough list entries", list.size() > 0);
      final String message =  list.get(0);
      assertTrue("Incorrect message. Expected - Hello World, Actual - " + message, message.contains("Hello World"));
    } finally {
      root.removeAppender(appender);
      appender.stop();
    }
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

root.info("Hello");
appender.stop();

代码示例来源:origin: org.apache.logging.log4j/log4j-core

msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
root.info(MarkerManager.getMarker("EVENT"), msg);

代码示例来源:origin: org.apache.logging.log4j/log4j-core

msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
root.info(MarkerManager.getMarker("EVENT"), msg);

代码示例来源:origin: org.apache.logging.log4j/log4j-core

msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
root.info(MarkerManager.getMarker("EVENT"), msg);

代码示例来源:origin: org.apache.logging.log4j/log4j-core

final StructuredDataCollectionMessage collectionMessage = new StructuredDataCollectionMessage(messages);
root.info(MarkerManager.getMarker("EVENT"), collectionMessage);

代码示例来源:origin: org.apache.logging.log4j/log4j-core

root.setLevel(Level.DEBUG);
root.info("starting logger fields test");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

root.info("starting logger fields test");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

root.setLevel(Level.DEBUG);
root.info("starting logger fields test");

代码示例来源:origin: mulesoft/mule

@Override
public void info(String message, Object... params) {
 getLogger().info(message, params);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.put(MDCKEY2, MDCVALUE2);
root.info(LINE2);

代码示例来源:origin: mulesoft/mule

@Test
public void currentClassLoader() {
 logger.info(MESSAGE);
 verify(originalLogger).info(MESSAGE);
}

相关文章