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

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

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

LogManager.shutdown介绍

[英]Shutdown using the LoggerContext appropriate for the caller of this method. This is equivalent to calling LogManager.shutdown(false). This call is synchronous and will block until shut down is complete. This may include flushing pending log events over network connections.
[中]使用适用于此方法调用方的LoggerContext关闭。这相当于调用LogManager。关机(错误)。此调用是同步的,将一直阻止,直到关闭完成。这可能包括通过网络连接刷新挂起的日志事件。

代码示例

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

/**
 * Shutdown using the LoggerContext appropriate for the caller of this method.
 * This is equivalent to calling {@code LogManager.shutdown(false)}.
 *
 * This call is synchronous and will block until shut down is complete.
 * This may include flushing pending log events over network connections.
 *
 * @since 2.6
 */
public static void shutdown() {
  shutdown(false);
}

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

/**
 * Cleans up the logger configuration. Should be used in unit tests only for sequential tests run with
 * different configurations
 */
static void cleanup() {
  synchronized (mux) {
    if (inited)
      LogManager.shutdown();
    inited = false;
  }
}

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

/**
 * Shutdown the logging system if the logging system supports it.
 * This is equivalent to calling {@code LogManager.shutdown(LogManager.getContext(currentContext))}.
 *
 * This call is synchronous and will block until shut down is complete.
 * This may include flushing pending log events over network connections.
 *
 * @param currentContext if true a default LoggerContext (may not be the LoggerContext used to create a Logger
 *            for the calling class) will be used.
 *            If false the LoggerContext appropriate for the caller of this method is used. For
 *            example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be
 *            used and if the caller is a class in the container's classpath then a different LoggerContext may
 *            be used.
 * @since 2.6
 */
public static void shutdown(final boolean currentContext) {
  shutdown(getContext(currentContext));
}

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

@AfterClass
public static void tearDown() {
 System.clearProperty("log4j.configurationFile");
 LogManager.shutdown();
}

代码示例来源:origin: loklak/loklak_server

public void run() {
    try {
      DAO.log("catched main termination signal");
      LoklakInstallation.server.stop();
      DAO.close();
      DAO.log("main terminated, goodby.");
      DAO.log("Shutting down log4j2");
      LogManager.shutdown();
    } catch (Exception e) {
    }
  }
});

代码示例来源:origin: loklak/loklak_server

public void run() {
    try {
      DAO.log("catched main termination signal");
      LoklakServer.dumpImporter.shutdown();
      LoklakServer.queuedIndexing.shutdown();
      LoklakServer.caretaker.shutdown();
      LoklakServer.server.stop();
      DAO.close();
      TwitterScraper.executor.shutdown();
      LoklakServer.harvester.stop();
      DAO.log("main terminated, goodby.");
      //LoklakServer.saveConfig();
      DAO.log("saved customized_config.properties");
      DAO.log("Shutting down log4j2");
      LogManager.shutdown();
    } catch (Exception e) {
    }
  }
});

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

LogManager.shutdown();

代码示例来源:origin: torodb/stampede

LogManager.shutdown();
 System.exit(1);
String causeMessage = rootCause.getMessage() != null ? rootCause.getMessage() : 
  "internal error";
LogManager.shutdown();
JCommander.getConsole().println("Fatal error while ToroDB was starting: " + causeMessage);
System.exit(1);

代码示例来源:origin: com.github.almasb/fxgl-core

@Override
  public void close() {
    LogManager.shutdown();
  }
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * Shutdown using the LoggerContext appropriate for the caller of this method.
 * This is equivalent to calling {@code LogManager.shutdown(false)}.
 *
 * This call is synchronous and will block until shut down is complete.
 * This may include flushing pending log events over network connections.
 *
 * @since 2.6
 */
public static void shutdown() {
  shutdown(false);
}

代码示例来源:origin: org.apache.ignite/ignite-log4j2

/**
 * Cleans up the logger configuration. Should be used in unit tests only for sequential tests run with
 * different configurations
 */
static void cleanup() {
  synchronized (mux) {
    if (inited)
      LogManager.shutdown();
    inited = false;
  }
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public void stop(final BundleContext context) throws Exception {
  provideRegistration.unregister();
  this.contextRef.compareAndSet(context, null);
  LogManager.shutdown();
}

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

public void shutdown() {
    try {
      // We disabled the log4j shutdown hook to gain more control and keep logs during shutdown.
      // See #disableLog4jShutdownHook()
      // Otoh that means we need to shutdown Log4j manually.
      // So here we go...
      LogManager.shutdown();
    } catch (final Exception e) {
      System.out.println("A problem happened when shutting down Log4j: " + e + "\n" + e.getMessage());
    }
  }
}

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

public void shutdown() {
    try {
      // We disabled the log4j shutdown hook to gain more control and keep logs during shutdown.
      // See #disableLog4jShutdownHook()
      // Otoh that means we need to shutdown Log4j manually.
      // So here we go...
      LogManager.shutdown();
    } catch (final Exception e) {
      System.out.println("A problem happened when shutting down Log4j: " + e + "\n" + e.getMessage());
    }
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * Shuts down Log4J.
 */
public static void shutdownLogging() {
  log("Shutting down Log4J");
  LogManager.shutdown();
}

代码示例来源:origin: com.github.emc-mongoose/mongoose-ui

public static void shutdown() {
  try {
    DaemonBase.closeAll();
    LogManager.shutdown();
  } catch(final Throwable cause) {
    cause.printStackTrace(System.err);
  }
}
//

代码示例来源:origin: FINRAOS/herd

@Override
public void shutdownLogging()
{
  LogManager.shutdown();
}

代码示例来源:origin: emc-mongoose/mongoose

static void shutdown() throws InterruptRunException {
 try {
  DaemonBase.closeAll();
 } catch (final InterruptRunException e) {
  throw e;
 } catch (final Throwable cause) {
  cause.printStackTrace(System.err);
 } finally {
  LogManager.shutdown();
 }
}

代码示例来源:origin: semuxproject/semux-core

/**
   * Call registered shutdown hooks in the order of registration.
   */
  private static synchronized void shutdownHook() {
    // shutdown hooks
    for (Pair<String, Runnable> r : shutdownHooks) {
      try {
        logger.info("Shutting down {}", r.getLeft());
        r.getRight().run();
      } catch (Exception e) {
        logger.info("Failed to shutdown {}", r.getLeft(), e);
      }
    }

    // flush log4j async loggers
    LogManager.shutdown();
  }
}

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

public static synchronized void halt(int status) {
  LOGGER.fatal("JVM halting with status {}; thread dump at halt: {}", status, ThreadDumpUtil.takeDumpString());
  // try to give time for the log to be emitted...
  LogManager.shutdown();
  Runtime.getRuntime().halt(status);
}

相关文章