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

x33g5p2x  于2022-01-20 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(252)

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

Hierarchy.shutdown介绍

[英]Shutting down a hierarchy will safely close and remove all appenders in all categories including the root logger.

Some appenders such as org.apache.log4j.net.SocketAppenderand AsyncAppender need to be closed before the application exists. Otherwise, pending logging events might be lost.

The shutdown method is careful to close nested appenders before closing regular appenders. This is allows configurations where a regular appender is attached to a logger and again to a nested appender.
[中]关闭层次结构将安全关闭并删除所有类别中的所有附加器,包括根记录器。
一些附加器,如org。阿帕奇。log4j。网在应用程序存在之前,需要关闭SocketAppender和AsyncAppender。否则,挂起的日志记录事件可能会丢失。
shutdown方法在关闭常规追加器之前会小心地关闭嵌套追加器。这允许将常规追加器连接到记录器,然后再连接到嵌套追加器的配置。

代码示例

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

shutdown(); // nested locks are OK

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

shutdown(); // nested locks are OK

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

/**
  Reset all values contained in this hierarchy instance to their
  default.  This removes all appenders from all categories, sets
  the level of all non-root categories to <code>null</code>,
  sets their additivity flag to <code>true</code> and sets the level
  of the root logger to {@link Level#DEBUG DEBUG}.  Moreover,
  message disabling is set its default "off" value.
  <p>Existing categories are not removed. They are just reset.
  <p>This method should be used sparingly and with care as it will
  block all logging until it is completed.</p>
  @since 0.8.5 */
public
void resetConfiguration() {
 getRootLogger().setLevel((Level) Level.DEBUG);
 root.setResourceBundle(null);
 setThreshold(Level.ALL);
 // the synchronization is needed to prevent JDK 1.2.x hashtable
 // surprises
 synchronized(ht) {
  shutdown(); // nested locks are OK
  Enumeration cats = getCurrentLoggers();
  while(cats.hasMoreElements()) {
 Logger c = (Logger) cats.nextElement();
 c.setLevel(null);
 c.setAdditivity(true);
 c.setResourceBundle(null);
  }
 }
 rendererMap.clear();
}

代码示例来源:origin: com.ironoreserver/com.ironoreserver.common

@Override
  public void run() {
    defaultLoggerRepository.shutdown();
  }
});

代码示例来源:origin: org.apache.portals.jetspeed-2/jetspeed-webapp-logging

public void contextDestroyed(ServletContextEvent event)
  {
    if ( log != null )
    {
      log.info("Shutting down IsolatedLog4JLogger");
      log = null;
    }
    // flush Logger cache which might be kept in a shared context if
    // commons-logging isn't loaded through this ContextClassLoader
    LogFactory.release(Thread.currentThread().getContextClassLoader());
    // shutdown Log4J hierarchy (log4J keeps log files locked on Windows otherwise)
    if (isolatedHierarchy != null)
    {
      isolatedHierarchy.shutdown();
    }
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

shutdown(); // nested locks are OK

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

shutdown(); // nested locks are OK

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

/**
  Reset all values contained in this hierarchy instance to their
  default.  This removes all appenders from all categories, sets
  the level of all non-root categories to <code>null</code>,
  sets their additivity flag to <code>true</code> and sets the level
  of the root logger to {@link Level#DEBUG DEBUG}.  Moreover,
  message disabling is set its default "off" value.
  <p>Existing categories are not removed. They are just reset.
  <p>This method should be used sparingly and with care as it will
  block all logging until it is completed.</p>
  @since 0.8.5 */
public
void resetConfiguration() {
 getRootLogger().setLevel((Level) Level.DEBUG);
 root.setResourceBundle(null);
 setThreshold(Level.ALL);
 // the synchronization is needed to prevent JDK 1.2.x hashtable
 // surprises
 synchronized(ht) {
  shutdown(); // nested locks are OK
  Enumeration cats = getCurrentLoggers();
  while(cats.hasMoreElements()) {
 Logger c = (Logger) cats.nextElement();
 c.setLevel(null);
 c.setAdditivity(true);
 c.setResourceBundle(null);
  }
 }
 rendererMap.clear();
}

代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j

shutdown(); // nested locks are OK

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.log4j

/**
  Reset all values contained in this hierarchy instance to their
  default.  This removes all appenders from all categories, sets
  the level of all non-root categories to <code>null</code>,
  sets their additivity flag to <code>true</code> and sets the level
  of the root logger to {@link Level#DEBUG DEBUG}.  Moreover,
  message disabling is set its default "off" value.
  <p>Existing categories are not removed. They are just reset.
  <p>This method should be used sparingly and with care as it will
  block all logging until it is completed.</p>
  @since 0.8.5 */
public
void resetConfiguration() {
 getRootLogger().setLevel((Level) Level.DEBUG);
 root.setResourceBundle(null);
 setThreshold(Level.ALL);
 // the synchronization is needed to prevent JDK 1.2.x hashtable
 // surprises
 synchronized(ht) {
  shutdown(); // nested locks are OK
  Enumeration cats = getCurrentLoggers();
  while(cats.hasMoreElements()) {
 Logger c = (Logger) cats.nextElement();
 c.setLevel(null);
 c.setAdditivity(true);
 c.setResourceBundle(null);
  }
 }
 rendererMap.clear();
}

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

/**
  Reset all values contained in this hierarchy instance to their
  default.  This removes all appenders from all categories, sets
  the level of all non-root categories to <code>null</code>,
  sets their additivity flag to <code>true</code> and sets the level
  of the root logger to {@link Level#DEBUG DEBUG}.  Moreover,
  message disabling is set its default "off" value.
  <p>Existing categories are not removed. They are just reset.
  <p>This method should be used sparingly and with care as it will
  block all logging until it is completed.</p>
  @since 0.8.5 */
public
void resetConfiguration() {
 getRootLogger().setLevel((Level) Level.DEBUG);
 root.setResourceBundle(null);
 setThreshold(Level.ALL);
 // the synchronization is needed to prevent JDK 1.2.x hashtable
 // surprises
 synchronized(ht) {
  shutdown(); // nested locks are OK
  Enumeration cats = getCurrentLoggers();
  while(cats.hasMoreElements()) {
 Logger c = (Logger) cats.nextElement();
 c.setLevel(null);
 c.setAdditivity(true);
 c.setResourceBundle(null);
  }
 }
 rendererMap.clear();
}

相关文章