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

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

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

LogManager.shutdown介绍

[英]No-op implementation.
[中]没有op实现。

代码示例

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

  1. /**
  2. Calling this method will <em>safely</em> close and remove all
  3. appenders in all the categories including root contained in the
  4. default hierachy.
  5. <p>Some appenders such as {@link org.apache.log4j.net.SocketAppender}
  6. and {@link AsyncAppender} need to be closed before the
  7. application exists. Otherwise, pending logging events might be
  8. lost.
  9. <p>The <code>shutdown</code> method is careful to close nested
  10. appenders before closing regular appenders. This is allows
  11. configurations where a regular appender is attached to a category
  12. and again to a nested appender.
  13. @deprecated Please use {@link LogManager#shutdown()} instead.
  14. @since 1.0
  15. */
  16. public
  17. static
  18. void shutdown() {
  19. LogManager.shutdown();
  20. }

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

  1. /**
  2. * Cleans up the logger configuration. Should be used in unit tests only for sequential tests run with
  3. * different configurations
  4. */
  5. static void cleanup() {
  6. synchronized (mux) {
  7. if (inited)
  8. LogManager.shutdown();
  9. inited = false;
  10. }
  11. }
  12. }

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

  1. @Override
  2. public void shutdown() {
  3. LogManager.shutdown();
  4. }

代码示例来源:origin: RipMeApp/ripme

  1. /**
  2. * Configures root logger, either for FILE output or just console.
  3. */
  4. public static void configureLogger() {
  5. LogManager.shutdown();
  6. String logFile = getConfigBoolean("log.save", false) ? "log4j.file.properties" : "log4j.properties";
  7. try (InputStream stream = Utils.class.getClassLoader().getResourceAsStream(logFile)) {
  8. if (stream == null) {
  9. PropertyConfigurator.configure("src/main/resources/" + logFile);
  10. } else {
  11. PropertyConfigurator.configure(stream);
  12. }
  13. LOGGER.info("Loaded " + logFile);
  14. } catch (IOException e) {
  15. LOGGER.error(e.getMessage(), e);
  16. }
  17. }

代码示例来源:origin: alibaba/jstorm

  1. /**
  2. * @param args Command line args
  3. */
  4. public static void main(String[] args) {
  5. boolean result = false;
  6. try {
  7. JstormMaster appMaster = new JstormMaster();
  8. LOG.info("Initializing Jstorm Master!");
  9. boolean doRun = appMaster.init(args);
  10. if (!doRun) {
  11. System.exit(JOYConstants.EXIT_SUCCESS);
  12. }
  13. appMaster.run();
  14. // LRS won't finish at all
  15. result = appMaster.finish();
  16. } catch (Throwable t) {
  17. LOG.fatal("Error running JstormMaster", t);
  18. LogManager.shutdown();
  19. ExitUtil.terminate(JOYConstants.EXIT_FAIL1, t);
  20. }
  21. if (result) {
  22. LOG.info("Application Master completed successfully. exiting");
  23. System.exit(JOYConstants.EXIT_SUCCESS);
  24. } else {
  25. LOG.info("Application Master failed. exiting");
  26. System.exit(JOYConstants.EXIT_FAIL2);
  27. }
  28. }

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

  1. if (!relinquishLoggingControl) LogManager.shutdown();
  2. LogFactory.release(Thread.currentThread().getContextClassLoader());

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Shut down log4j, properly releasing all file locks.
  3. * <p>This isn't strictly necessary, but recommended for shutting down
  4. * log4j in a scenario where the host VM stays alive (for example, when
  5. * shutting down an application in a J2EE environment).
  6. */
  7. public static void shutdownLogging() {
  8. LogManager.shutdown();
  9. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. Calling this method will <em>safely</em> close and remove all
  3. appenders in all the categories including root contained in the
  4. default hierachy.
  5. <p>Some appenders such as {@link org.apache.log4j.net.SocketAppender}
  6. and {@link AsyncAppender} need to be closed before the
  7. application exists. Otherwise, pending logging events might be
  8. lost.
  9. <p>The <code>shutdown</code> method is careful to close nested
  10. appenders before closing regular appenders. This is allows
  11. configurations where a regular appender is attached to a category
  12. and again to a nested appender.
  13. @deprecated Please use {@link LogManager#shutdown()} instead.
  14. @since 1.0
  15. */
  16. public
  17. static
  18. void shutdown() {
  19. LogManager.shutdown();
  20. }

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

  1. /**
  2. Calling this method will <em>safely</em> close and remove all
  3. appenders in all the categories including root contained in the
  4. default hierachy.
  5. <p>Some appenders such as {@link org.apache.log4j.net.SocketAppender}
  6. and {@link AsyncAppender} need to be closed before the
  7. application exists. Otherwise, pending logging events might be
  8. lost.
  9. <p>The <code>shutdown</code> method is careful to close nested
  10. appenders before closing regular appenders. This is allows
  11. configurations where a regular appender is attached to a category
  12. and again to a nested appender.
  13. @deprecated Please use {@link LogManager#shutdown()} instead.
  14. @since 1.0
  15. */
  16. public
  17. static
  18. void shutdown() {
  19. LogManager.shutdown();
  20. }

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

  1. /**
  2. * @param args Command line args
  3. */
  4. public static void main(String[] args) {
  5. boolean result = false;
  6. try {
  7. ApplicationMaster appMaster = new ApplicationMaster();
  8. LOG.info("Initializing ApplicationMaster");
  9. boolean doRun = appMaster.init(args);
  10. if (!doRun) {
  11. System.exit(0);
  12. }
  13. appMaster.run();
  14. result = appMaster.finish();
  15. } catch (Throwable t) {
  16. LOG.fatal("Error running ApplicationMaster", t);
  17. LogManager.shutdown();
  18. ExitUtil.terminate(1, t);
  19. }
  20. if (result) {
  21. LOG.info("Application Master completed successfully. exiting");
  22. System.exit(0);
  23. } else {
  24. LOG.info("Application Master failed. exiting");
  25. System.exit(2);
  26. }
  27. }

代码示例来源:origin: openmrs/openmrs-core

  1. LogManager.shutdown();

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

  1. /**
  2. * Cleans up the logger configuration. Should be used in unit tests only for sequential tests run with
  3. * different configurations
  4. */
  5. static void cleanup() {
  6. synchronized (mux) {
  7. if (inited)
  8. LogManager.shutdown();
  9. inited = false;
  10. }
  11. }
  12. }

代码示例来源:origin: springframework/spring-core

  1. /**
  2. * Shut down Log4J, properly releasing all file locks.
  3. * <p>This isn't strictly necessary, but recommended for shutting down
  4. * Log4J in a scenario where the host VM stays alive (for example, when
  5. * shutting down an application in a J2EE environment).
  6. */
  7. public static void shutdownLogging() {
  8. LogManager.shutdown();
  9. }

代码示例来源:origin: com.github.susom/server-logging

  1. @Override
  2. public void contextDestroyed(ServletContextEvent contextEvent) {
  3. ServletContext servletContext = contextEvent.getServletContext();
  4. String contextPath = servletContext.getContextPath();
  5. // Make sure locks on log files are released
  6. LogManager.shutdown();
  7. servletContext.log("Shutdown log4j for " + contextPath);
  8. }
  9. }

代码示例来源:origin: io.hops/hadoop-mapreduce-client-core

  1. public static synchronized void syncLogsShutdown(
  2. ScheduledExecutorService scheduler)
  3. {
  4. // flush standard streams
  5. //
  6. System.out.flush();
  7. System.err.flush();
  8. if (scheduler != null) {
  9. scheduler.shutdownNow();
  10. }
  11. // flush & close all appenders
  12. LogManager.shutdown();
  13. }

代码示例来源:origin: com.github.jiayuhan-it/hadoop-mapreduce-client-core

  1. public static synchronized void syncLogsShutdown(
  2. ScheduledExecutorService scheduler)
  3. {
  4. // flush standard streams
  5. //
  6. System.out.flush();
  7. System.err.flush();
  8. if (scheduler != null) {
  9. scheduler.shutdownNow();
  10. }
  11. // flush & close all appenders
  12. LogManager.shutdown();
  13. }

代码示例来源:origin: com.atlassian.jira/jira-core

  1. private void cleanupAfterOurselves(OpTimerFactory opTimerFactory)
  2. {
  3. cleanupThreadLocals(opTimerFactory);
  4. // and shutdown log4j for good measure
  5. LogManager.shutdown();
  6. }

代码示例来源:origin: com.github.jiayuhan-it/hadoop-mapreduce-client-app

  1. @Override
  2. protected void serviceStop() throws Exception {
  3. super.serviceStop();
  4. LogManager.shutdown();
  5. }

代码示例来源:origin: com.hazelcast.simulator/simulator

  1. @Override
  2. public void run() {
  3. if (!shutdownStarted.compareAndSet(false, true)) {
  4. return;
  5. }
  6. doRun();
  7. shutdownComplete.countDown();
  8. if (ensureProcessShutdown) {
  9. // ensures that log4j will always flush the log buffers
  10. LOGGER.info("Stopping log4j...");
  11. LogManager.shutdown();
  12. }
  13. }

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

  1. /**
  2. * Destroy the log service.
  3. */
  4. public void destroy() {
  5. LogManager.shutdown();
  6. XLog.Info.reset();
  7. XLogFilter.reset();
  8. }

相关文章