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

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

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

Logger.fatal介绍

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

代码示例

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

@Override
public void fatal(String format, Object... args) {
  logger.fatal(format, args);
}

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

@Override
public void fatal(String msg) {
  logger.fatal(msg);
}

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

void logWaitOnOperationsSevere(Logger alertLogger, long severeAlertMS) {
 // OSProcess.printStacks(0);
 alertLogger.fatal("This thread has been stalled for {} milliseconds "
   + "waiting for current operations to complete.  Something may be blocking operations.",
   severeAlertMS);
}

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

@Override
public void fatal(String msg, Throwable throwable) {
  logger.fatal(msg, throwable);
}

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

public JCAConnectionManagerImpl(ManagedConnectionFactory mcf,
  ConfiguredDataSourceProperties configs) {
 // Get the security info and form the Subject
 // Initialize the Pool.
 try {
  isActive = true;
  mannPoolCache = new ManagedPoolCacheImpl(mcf, null, null, this, configs);
 } catch (Exception ex) {
  logger.fatal(String.format(
    "JCAConnectionManagerImpl::Constructor: An exception was caught while initialising due to %s",
    ex.getLocalizedMessage()),
    ex);
 }
}

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

protected synchronized void fileDescriptorsExhausted() {
 if (!ulimitWarningIssued) {
  ulimitWarningIssued = true;
  logger.fatal(
    "This process is out of file descriptors.This will hamper communications and slow down the system.Any conserve-sockets setting is now being ignored.Please consider raising the descriptor limit.This alert is only issued once per process.");
  InternalDistributedSystem.getAnyInstance().setShareSockets(true);
  threadWantsOwnResources = new ThreadLocal();
 }
}

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

private ClientUpdateMessageImpl constructClientMessage(InternalCacheEvent event) {
 ClientUpdateMessageImpl clientMessage = null;
 EnumListenerEvent operation = event.getEventType();
 try {
  clientMessage = initializeMessage(operation, event);
 } catch (Exception e) {
  logger.fatal(String.format(
    "CacheClientNotifier: Cannot notify clients to perform operation %s on event %s",
    new Object[] {operation, event}),
    e);
 }
 return clientMessage;
}

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

protected synchronized void processException(ReplyException ex) {
 if (this.exception == null) { // only keep first exception
  this.exception = ex;
 } else if (logMultipleExceptions()) {
  if (!(ex.getCause() instanceof ConcurrentCacheModificationException)) {
   logger.fatal(
     "Exception received in ReplyMessage. Only one exception is passed back to caller. This exception is logged only.",
     ex);
  }
 }
}

代码示例来源: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: 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-default.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: 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.xml")) {
    LOG.fatal("\u001b[1;35mFatal message.\u001b[0m");
    LOG.error("\u001b[1;31mError message.\u001b[0m");
    LOG.warn("\u001b[0;33mWarning message.\u001b[0m");
    LOG.info("\u001b[0;32mInformation message.\u001b[0m");
    LOG.debug("\u001b[0;36mDebug message.\u001b[0m");
    LOG.trace("\u001b[0;30mTrace message.\u001b[0m");
    LOG.error("\u001b[1;31mError message.\u001b[0m", new IOException("test"));
  }
}

代码示例来源: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-style-name-ansi.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: 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

/**
 * Notes that an error has occurred in the agent and that it has shut down because of it.
 */
private void setServerError(final String message, final Throwable cause) {
 try {
  writeStatus(createStatus(this.basename, SHUTDOWN_PENDING_AFTER_FAILED_STARTUP,
    OSProcess.getId(), message, cause));
 } catch (Exception e) {
  logger.fatal(e.getMessage(), e);
  ExitCode.FATAL.doSystemExit();
 }
}

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

@Override
 void processLocally() {
  try {
   addToResults(member, finishBackupFactory.createFinishBackup(cache).run());
  } catch (IOException e) {
   logger.fatal("Failed to FinishBackup in " + member, e);
  }
 }
}

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

public void test(final String[] args) {
  System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable
  // System.out.println(System.getProperty("java.class.path"));
  final String config = args == null || args.length == 0 ? "target/test-classes/log4j2-console-style-ansi.xml"
      : args[0];
  try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config)) {
    final Logger logger = LogManager.getLogger(ConsoleAppenderAnsiStyleLayoutMain.class);
    logger.fatal("Fatal message.");
    logger.error("Error message.");
    logger.warn("Warning message.");
    logger.info("Information message.");
    logger.debug("Debug message.");
    logger.trace("Trace message.");
    logger.error("Error message.", new IOException("test"));
  }
}

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

@Override
 void processLocally() {
  try {
   addToResults(member,
     prepareBackupFactory.createPrepareBackup(member, cache, properties).run());
  } catch (IOException | InterruptedException e) {
   logger.fatal("Failed to PrepareBackup in " + member, e);
  }
 }
}

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

@Test
public void verifyFatalMessageLoggedWhenUncaughtExceptionIsCalled() {
 Logger logger = mock(Logger.class);
 Thread thread = mock(Thread.class);
 Throwable throwable = mock(Throwable.class);
 Implementation handler = new Implementation(logger, null);
 handler.uncaughtException(thread, throwable);
 verify(logger).fatal("Uncaught exception in thread " + thread, throwable);
}

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

@Override
public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
  final SecurityService securityService, long start) throws IOException {
 // requiresResponse = true; NOT NEEDED... ALWAYS SEND ERROR RESPONSE
 logger.fatal("{}: Unknown message type ({}) with tx: {} from {}",
   new Object[] {serverConnection.getName(),
     MessageType.getString(clientMessage.getMessageType()),
     Integer.valueOf(clientMessage.getTransactionId()),
     serverConnection.getSocketString()});
 writeErrorResponse(clientMessage, MessageType.UNKNOWN_MESSAGE_TYPE_ERROR, serverConnection);
 // responded = true; NOT NEEDED... ALWAYS SEND ERROR RESPONSE
}

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

@Test
  public void testMethodLogger() throws Exception {
    final ListAppender app = context.getListAppender("Method").clear();
    final Logger logger = context.getLogger("MethodLogger");
    logger.info("More messages.");
    logger.warn("CATASTROPHE INCOMING!");
    logger.error("ZOMBIES!!!");
    logger.fatal("brains~~~");
    logger.info("Itchy. Tasty.");
    final List<String> messages = app.getMessages();
    assertEquals("Incorrect number of messages.", 5, messages.size());
    for (final String message : messages) {
      assertEquals("Incorrect caller method name.", "testMethodLogger", message);
    }
  }
}

相关文章