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

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

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

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

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

  1. @Override
  2. public void fatal(String msg) {
  3. logger.fatal(msg);
  4. }

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

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

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

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

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

  1. public JCAConnectionManagerImpl(ManagedConnectionFactory mcf,
  2. ConfiguredDataSourceProperties configs) {
  3. // Get the security info and form the Subject
  4. // Initialize the Pool.
  5. try {
  6. isActive = true;
  7. mannPoolCache = new ManagedPoolCacheImpl(mcf, null, null, this, configs);
  8. } catch (Exception ex) {
  9. logger.fatal(String.format(
  10. "JCAConnectionManagerImpl::Constructor: An exception was caught while initialising due to %s",
  11. ex.getLocalizedMessage()),
  12. ex);
  13. }
  14. }

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

  1. protected synchronized void fileDescriptorsExhausted() {
  2. if (!ulimitWarningIssued) {
  3. ulimitWarningIssued = true;
  4. logger.fatal(
  5. "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.");
  6. InternalDistributedSystem.getAnyInstance().setShareSockets(true);
  7. threadWantsOwnResources = new ThreadLocal();
  8. }
  9. }

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

  1. private ClientUpdateMessageImpl constructClientMessage(InternalCacheEvent event) {
  2. ClientUpdateMessageImpl clientMessage = null;
  3. EnumListenerEvent operation = event.getEventType();
  4. try {
  5. clientMessage = initializeMessage(operation, event);
  6. } catch (Exception e) {
  7. logger.fatal(String.format(
  8. "CacheClientNotifier: Cannot notify clients to perform operation %s on event %s",
  9. new Object[] {operation, event}),
  10. e);
  11. }
  12. return clientMessage;
  13. }

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

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

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

代码示例来源: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-style-name-ansi.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: 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. /**
  2. * Notes that an error has occurred in the agent and that it has shut down because of it.
  3. */
  4. private void setServerError(final String message, final Throwable cause) {
  5. try {
  6. writeStatus(createStatus(this.basename, SHUTDOWN_PENDING_AFTER_FAILED_STARTUP,
  7. OSProcess.getId(), message, cause));
  8. } catch (Exception e) {
  9. logger.fatal(e.getMessage(), e);
  10. ExitCode.FATAL.doSystemExit();
  11. }
  12. }

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

  1. @Override
  2. void processLocally() {
  3. try {
  4. addToResults(member, finishBackupFactory.createFinishBackup(cache).run());
  5. } catch (IOException e) {
  6. logger.fatal("Failed to FinishBackup in " + member, e);
  7. }
  8. }
  9. }

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

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

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

  1. @Override
  2. void processLocally() {
  3. try {
  4. addToResults(member,
  5. prepareBackupFactory.createPrepareBackup(member, cache, properties).run());
  6. } catch (IOException | InterruptedException e) {
  7. logger.fatal("Failed to PrepareBackup in " + member, e);
  8. }
  9. }
  10. }

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

  1. @Test
  2. public void verifyFatalMessageLoggedWhenUncaughtExceptionIsCalled() {
  3. Logger logger = mock(Logger.class);
  4. Thread thread = mock(Thread.class);
  5. Throwable throwable = mock(Throwable.class);
  6. Implementation handler = new Implementation(logger, null);
  7. handler.uncaughtException(thread, throwable);
  8. verify(logger).fatal("Uncaught exception in thread " + thread, throwable);
  9. }

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

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

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

  1. @Test
  2. public void testMethodLogger() throws Exception {
  3. final ListAppender app = context.getListAppender("Method").clear();
  4. final Logger logger = context.getLogger("MethodLogger");
  5. logger.info("More messages.");
  6. logger.warn("CATASTROPHE INCOMING!");
  7. logger.error("ZOMBIES!!!");
  8. logger.fatal("brains~~~");
  9. logger.info("Itchy. Tasty.");
  10. final List<String> messages = app.getMessages();
  11. assertEquals("Incorrect number of messages.", 5, messages.size());
  12. for (final String message : messages) {
  13. assertEquals("Incorrect caller method name.", "testMethodLogger", message);
  14. }
  15. }
  16. }

相关文章