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

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

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

Logger.info介绍

[英]Logs a message CharSequence with the Level#INFO level.
[中]记录级别为#INFO Level的消息字符序列。

代码示例

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

protected void setBatchSize(int batchSize) {
 int currentBatchSize = this.batchSize;
 if (batchSize <= 0) {
  this.batchSize = 1;
  logger.warn(
    "Attempting to set the batch size from {} to {} events failed. Instead it was set to 1.",
    new Object[] {currentBatchSize, batchSize});
 } else {
  this.batchSize = batchSize;
  logger.info("Set the batch size from {} to {} events",
    new Object[] {currentBatchSize, this.batchSize});
 }
}

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

private void debug(String message, Object... params) {
 if (logger.isDebugEnabled()) {
  logger.debug(message, params);
 } else if (logger.isInfoEnabled() && DEBUG) {
  logger.info(message, params);
 }
}

代码示例来源:origin: blynkkk/blynk-server

@Override
public void run() {
  try {
    log.info("Start removing unused reporting data...");
    long now = System.currentTimeMillis();
    int result = removeUnsedInHistoryGraphData();
    lastStart = now;
    log.info("Removed {} files. Time : {} ms.", result, System.currentTimeMillis() - now);
  } catch (Throwable t) {
    log.error("Error removing unused reporting data.", t);
  }
}

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

public static void main(final String[] args) {
  try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
      "target/test-classes/log4j2-console-highlight-logback.xml")) {
    LOG.fatal("Fatal message.");
    LOG.error("Error message.");
    LOG.warn("Warning message.");
    LOG.info("Information message.");
    LOG.debug("Debug message.");
    LOG.trace("Trace message.");
    LOG.error("Error message.", new IOException("test"));
  }
}

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

/**
 * Constructor.
 *
 * @param maximumTimeBetweenPings The maximum time allowed between pings before determining the
 *        client has died and interrupting its sockets
 */
protected ClientHealthMonitorThread(int maximumTimeBetweenPings) {
 super("ClientHealthMonitor Thread");
 // Set the client connection timeout
 this._maximumTimeBetweenPings = maximumTimeBetweenPings;
 // LOG:CONFIG: changed from config to info
 logger.info("ClientHealthMonitorThread maximum allowed time between pings: {}",
   this._maximumTimeBetweenPings);
 if (maximumTimeBetweenPings == 0) {
  if (logger.isDebugEnabled()) {
   logger.debug("zero ping interval detected", new Exception(
     "stack trace"));
  }
 }
}

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

@Test
public void testClassLogger() throws Exception {
  final ListAppender app = context.getListAppender("Class").clear();
  final Logger logger = context.getLogger("ClassLogger");
  logger.info("Ignored message contents.");
  logger.warn("Verifying the caller class is still correct.");
  logger.error("Hopefully nobody breaks me!");
  final List<String> messages = app.getMessages();
  assertEquals("Incorrect number of messages.", 3, messages.size());
  for (final String message : messages) {
    assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
  }
}

代码示例来源:origin: blynkkk/blynk-server

private static void completeLogin(Channel channel, Session session, User user,
                 DashBoard dash, Device device, int msgId) {
  log.debug("completeLogin. {}", channel);
  session.addHardChannel(channel);
  channel.writeAndFlush(ACCEPTED);
  String responseBody = String.valueOf(dash.id) + DEVICE_SEPARATOR + device.id;
  session.sendToApps(HARDWARE_CONNECTED, msgId, dash.id, responseBody);
  log.info("{} mqtt hardware joined.", user.email);
}

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

logger.info("Cluster configuration service is disabled");
 return;
 logger.info("Cluster configuration service is already started.");
 return;
 logger.info("Cluster configuration service not enabled as it is only supported "
   + "in dedicated locators");
 return;
 logger.info(
   "Cluster configuration service start up completed successfully and is now running ....");
 isSharedConfigurationStarted = true;
} catch (CancelException | LockServiceDestroyedException e) {
 if (logger.isDebugEnabled()) {
  logger.debug("Cluster configuration start up was cancelled", e);
 logger.error(e.getMessage(), e);

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

void writeLog(Logger logger) {
  switch (this.level) {
   case "info":
    logger.info(getMessage());
    break;
   case "error":
    logger.error(getMessage());
    break;
   case "debug":
    logger.debug(getMessage());
  }
 }
}

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

@Test
public void validateXmlSchema() throws Exception {
  final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
  file.delete();
  final Logger log = LogManager.getLogger("com.foo.Bar");
  log.warn("Message 1");
  log.info("Message 2");
  log.debug("Message 3");
  Configurator.shutdown(this.loggerContext);
  this.validateXmlSchema(file);
}

代码示例来源:origin: javamelody/javamelody

/** {@inheritDoc} */
@Override
public void logHttpRequest(HttpServletRequest httpRequest, String requestName, long duration,
    boolean systemError, int responseSize, String loggerName) {
  final org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager
      .getLogger(loggerName);
  if (logger.isInfoEnabled()) {
    logger.info(LOG.buildLogMessage(httpRequest, duration, systemError, responseSize));
  }
}

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

if (logger.isInfoEnabled()) {
 logger.info(
   "ClientStatsManager, intializing the statistics...");
logger.warn(String.format("ClientStatsManager, %s are not available.",
  "CachePerfStats"));
logger.warn(String.format("ClientStatsManager, %s are not available.",
  "VMStats"));

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

/**
 * Pause for the specified milliseconds. Make sure system clock has advanced by the specified
 * number of millis before returning.
 *
 * @deprecated Please use {@link GeodeAwaitility} instead.
 */
public static void pause(final int milliseconds) {
 if (milliseconds >= 1000 || logger.isDebugEnabled()) { // check for debug but log at info
  logger.info("Pausing for {} ms...", milliseconds);
 }
 final long target = System.currentTimeMillis() + milliseconds;
 try {
  for (;;) {
   long msLeft = target - System.currentTimeMillis();
   if (msLeft <= 0) {
    break;
   }
   Thread.sleep(msLeft);
  }
 } catch (InterruptedException e) {
  Assert.fail("interrupted", e);
 }
}

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

public static void main(final String[] args) {
  System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable
  try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
      "target/test-classes/log4j2-console-highlight.xml")) {
    LOG.fatal("Fatal message.");
    LOG.error("Error message.");
    LOG.warn("Warning message.");
    LOG.info("Information message.");
    LOG.debug("Debug message.");
    LOG.trace("Trace message.");
    LOG.error("Error message.", new IOException("test"));
  }
}

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

@Override
public void removeUnfinishedStartup(InternalDistributedMember m, boolean departed) {
 synchronized (unfinishedStartupsLock) {
  if (logger.isDebugEnabled()) {
   logger.debug("removeUnfinishedStartup for {} wtih {}", m, unfinishedStartups);
  }
  if (unfinishedStartups == null)
   return; // not yet done with startup
  if (!unfinishedStartups.remove(m))
   return;
  String msg = null;
  if (departed) {
   msg =
     "Stopped waiting for startup reply from <{}> because the peer departed the view.";
  } else {
   msg =
     "Stopped waiting for startup reply from <{}> because the reply was finally received.";
  }
  logger.info(msg, m);
  int numLeft = unfinishedStartups.size();
  if (numLeft != 0) {
   logger.info("Still awaiting {} response(s) from: {}.",
     new Object[] {Integer.valueOf(numLeft), unfinishedStartups});
  }
 } // synchronized
}

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

public PdxType getType(int typeId) {
 PdxType pdxType = this.idToType.get(typeId);
 if (pdxType != null) {
  return pdxType;
 }
 synchronized (this) {
  pdxType = this.distributedTypeRegistry.getType(typeId);
  if (pdxType != null) {
   this.idToType.put(typeId, pdxType);
   this.typeToId.put(pdxType, typeId);
   if (logger.isInfoEnabled()) {
    logger.info("Adding: {}", pdxType.toFormattedString());
   }
   if (logger.isDebugEnabled()) {
    logger.debug("Adding entry into pdx type registry, typeId: {}  {}", typeId, pdxType);
   }
   return pdxType;
  }
 }
 return null;
}

代码示例来源:origin: medcl/elasticsearch-analysis-ik

/**
 * 加载远程扩展词典到主词库表
 */
private void loadRemoteExtDict() {
  List<String> remoteExtDictFiles = getRemoteExtDictionarys();
  for (String location : remoteExtDictFiles) {
    logger.info("[Dict Loading] " + location);
    List<String> lists = getRemoteWords(location);
    // 如果找不到扩展的字典,则忽略
    if (lists == null) {
      logger.error("[Dict Loading] " + location + "加载失败");
      continue;
    }
    for (String theWord : lists) {
      if (theWord != null && !"".equals(theWord.trim())) {
        // 加载扩展词典数据到主内存词典中
        logger.info(theWord);
        _MainDict.fillSegment(theWord.trim().toLowerCase().toCharArray());
      }
    }
  }
}

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

@Override
protected void handleStateChange(DiskState next, String pct, String critcalMessage) {
 Object[] args = new Object[] {dir.getAbsolutePath(), pct};
 switch (next) {
  case NORMAL:
   logger.info(LogMarker.DISK_STORE_MONITOR_MARKER,
     "The disk volume {} for log files has returned to normal usage levels and is {} full.",
     args);
   break;
  case WARN:
  case CRITICAL:
   logger.warn(LogMarker.DISK_STORE_MONITOR_MARKER,
     "The disk volume {} for log files has exceeded the warning usage threshold and is {} full.",
     args);
   break;
 }
}

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

logger.error("event 1 - gets taken off the queue");
logger.warn("event 2");
logger.info("event 3");
logger.info("event 4");
while (asyncAppender.getQueueRemainingCapacity() == 0) {
logger.info("event 5 - now the queue is full");
assertEquals("queue remaining capacity", 0, asyncAppender.getQueueRemainingCapacity());
assertEquals("EventRouter invocations", 0, policy.queueFull.get());

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

private boolean recover(InetSocketAddress other) {
 try {
  logger.info("Peer locator attempting to recover from " + other);
  TcpClient client = new TcpClient();
  Object response = client.requestToServer(other.getAddress(), other.getPort(),
    new GetViewRequest(), 20000, true);
  if (response instanceof GetViewResponse) {
   this.view = ((GetViewResponse) response).getView();
   logger.info("Peer locator recovered initial membership of {}", view);
   return true;
  }
 } catch (IOException | ClassNotFoundException ex) {
  logger.debug("Peer locator could not recover membership view from {}: {}", other,
    ex.getMessage());
 }
 logger.info("Peer locator was unable to recover state from this locator");
 return false;
}

相关文章