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

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

本文整理了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

  1. protected void setBatchSize(int batchSize) {
  2. int currentBatchSize = this.batchSize;
  3. if (batchSize <= 0) {
  4. this.batchSize = 1;
  5. logger.warn(
  6. "Attempting to set the batch size from {} to {} events failed. Instead it was set to 1.",
  7. new Object[] {currentBatchSize, batchSize});
  8. } else {
  9. this.batchSize = batchSize;
  10. logger.info("Set the batch size from {} to {} events",
  11. new Object[] {currentBatchSize, this.batchSize});
  12. }
  13. }

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

  1. private void debug(String message, Object... params) {
  2. if (logger.isDebugEnabled()) {
  3. logger.debug(message, params);
  4. } else if (logger.isInfoEnabled() && DEBUG) {
  5. logger.info(message, params);
  6. }
  7. }

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

  1. @Override
  2. public void run() {
  3. try {
  4. log.info("Start removing unused reporting data...");
  5. long now = System.currentTimeMillis();
  6. int result = removeUnsedInHistoryGraphData();
  7. lastStart = now;
  8. log.info("Removed {} files. Time : {} ms.", result, System.currentTimeMillis() - now);
  9. } catch (Throwable t) {
  10. log.error("Error removing unused reporting data.", t);
  11. }
  12. }

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

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

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

  1. /**
  2. * Constructor.
  3. *
  4. * @param maximumTimeBetweenPings The maximum time allowed between pings before determining the
  5. * client has died and interrupting its sockets
  6. */
  7. protected ClientHealthMonitorThread(int maximumTimeBetweenPings) {
  8. super("ClientHealthMonitor Thread");
  9. // Set the client connection timeout
  10. this._maximumTimeBetweenPings = maximumTimeBetweenPings;
  11. // LOG:CONFIG: changed from config to info
  12. logger.info("ClientHealthMonitorThread maximum allowed time between pings: {}",
  13. this._maximumTimeBetweenPings);
  14. if (maximumTimeBetweenPings == 0) {
  15. if (logger.isDebugEnabled()) {
  16. logger.debug("zero ping interval detected", new Exception(
  17. "stack trace"));
  18. }
  19. }
  20. }

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

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

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

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

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

  1. logger.info("Cluster configuration service is disabled");
  2. return;
  3. logger.info("Cluster configuration service is already started.");
  4. return;
  5. logger.info("Cluster configuration service not enabled as it is only supported "
  6. + "in dedicated locators");
  7. return;
  8. logger.info(
  9. "Cluster configuration service start up completed successfully and is now running ....");
  10. isSharedConfigurationStarted = true;
  11. } catch (CancelException | LockServiceDestroyedException e) {
  12. if (logger.isDebugEnabled()) {
  13. logger.debug("Cluster configuration start up was cancelled", e);
  14. logger.error(e.getMessage(), e);

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

  1. void writeLog(Logger logger) {
  2. switch (this.level) {
  3. case "info":
  4. logger.info(getMessage());
  5. break;
  6. case "error":
  7. logger.error(getMessage());
  8. break;
  9. case "debug":
  10. logger.debug(getMessage());
  11. }
  12. }
  13. }

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

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

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

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

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

  1. if (logger.isInfoEnabled()) {
  2. logger.info(
  3. "ClientStatsManager, intializing the statistics...");
  4. logger.warn(String.format("ClientStatsManager, %s are not available.",
  5. "CachePerfStats"));
  6. logger.warn(String.format("ClientStatsManager, %s are not available.",
  7. "VMStats"));

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

  1. /**
  2. * Pause for the specified milliseconds. Make sure system clock has advanced by the specified
  3. * number of millis before returning.
  4. *
  5. * @deprecated Please use {@link GeodeAwaitility} instead.
  6. */
  7. public static void pause(final int milliseconds) {
  8. if (milliseconds >= 1000 || logger.isDebugEnabled()) { // check for debug but log at info
  9. logger.info("Pausing for {} ms...", milliseconds);
  10. }
  11. final long target = System.currentTimeMillis() + milliseconds;
  12. try {
  13. for (;;) {
  14. long msLeft = target - System.currentTimeMillis();
  15. if (msLeft <= 0) {
  16. break;
  17. }
  18. Thread.sleep(msLeft);
  19. }
  20. } catch (InterruptedException e) {
  21. Assert.fail("interrupted", e);
  22. }
  23. }

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

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

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

  1. @Override
  2. public void removeUnfinishedStartup(InternalDistributedMember m, boolean departed) {
  3. synchronized (unfinishedStartupsLock) {
  4. if (logger.isDebugEnabled()) {
  5. logger.debug("removeUnfinishedStartup for {} wtih {}", m, unfinishedStartups);
  6. }
  7. if (unfinishedStartups == null)
  8. return; // not yet done with startup
  9. if (!unfinishedStartups.remove(m))
  10. return;
  11. String msg = null;
  12. if (departed) {
  13. msg =
  14. "Stopped waiting for startup reply from <{}> because the peer departed the view.";
  15. } else {
  16. msg =
  17. "Stopped waiting for startup reply from <{}> because the reply was finally received.";
  18. }
  19. logger.info(msg, m);
  20. int numLeft = unfinishedStartups.size();
  21. if (numLeft != 0) {
  22. logger.info("Still awaiting {} response(s) from: {}.",
  23. new Object[] {Integer.valueOf(numLeft), unfinishedStartups});
  24. }
  25. } // synchronized
  26. }

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

  1. public PdxType getType(int typeId) {
  2. PdxType pdxType = this.idToType.get(typeId);
  3. if (pdxType != null) {
  4. return pdxType;
  5. }
  6. synchronized (this) {
  7. pdxType = this.distributedTypeRegistry.getType(typeId);
  8. if (pdxType != null) {
  9. this.idToType.put(typeId, pdxType);
  10. this.typeToId.put(pdxType, typeId);
  11. if (logger.isInfoEnabled()) {
  12. logger.info("Adding: {}", pdxType.toFormattedString());
  13. }
  14. if (logger.isDebugEnabled()) {
  15. logger.debug("Adding entry into pdx type registry, typeId: {} {}", typeId, pdxType);
  16. }
  17. return pdxType;
  18. }
  19. }
  20. return null;
  21. }

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

  1. /**
  2. * 加载远程扩展词典到主词库表
  3. */
  4. private void loadRemoteExtDict() {
  5. List<String> remoteExtDictFiles = getRemoteExtDictionarys();
  6. for (String location : remoteExtDictFiles) {
  7. logger.info("[Dict Loading] " + location);
  8. List<String> lists = getRemoteWords(location);
  9. // 如果找不到扩展的字典,则忽略
  10. if (lists == null) {
  11. logger.error("[Dict Loading] " + location + "加载失败");
  12. continue;
  13. }
  14. for (String theWord : lists) {
  15. if (theWord != null && !"".equals(theWord.trim())) {
  16. // 加载扩展词典数据到主内存词典中
  17. logger.info(theWord);
  18. _MainDict.fillSegment(theWord.trim().toLowerCase().toCharArray());
  19. }
  20. }
  21. }
  22. }

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

  1. @Override
  2. protected void handleStateChange(DiskState next, String pct, String critcalMessage) {
  3. Object[] args = new Object[] {dir.getAbsolutePath(), pct};
  4. switch (next) {
  5. case NORMAL:
  6. logger.info(LogMarker.DISK_STORE_MONITOR_MARKER,
  7. "The disk volume {} for log files has returned to normal usage levels and is {} full.",
  8. args);
  9. break;
  10. case WARN:
  11. case CRITICAL:
  12. logger.warn(LogMarker.DISK_STORE_MONITOR_MARKER,
  13. "The disk volume {} for log files has exceeded the warning usage threshold and is {} full.",
  14. args);
  15. break;
  16. }
  17. }

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

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

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

  1. private boolean recover(InetSocketAddress other) {
  2. try {
  3. logger.info("Peer locator attempting to recover from " + other);
  4. TcpClient client = new TcpClient();
  5. Object response = client.requestToServer(other.getAddress(), other.getPort(),
  6. new GetViewRequest(), 20000, true);
  7. if (response instanceof GetViewResponse) {
  8. this.view = ((GetViewResponse) response).getView();
  9. logger.info("Peer locator recovered initial membership of {}", view);
  10. return true;
  11. }
  12. } catch (IOException | ClassNotFoundException ex) {
  13. logger.debug("Peer locator could not recover membership view from {}: {}", other,
  14. ex.getMessage());
  15. }
  16. logger.info("Peer locator was unable to recover state from this locator");
  17. return false;
  18. }

相关文章