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

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

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

LogManager.resetConfiguration介绍

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

代码示例

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

  1. /**
  2. Reset the default hierarchy to its defaut. It is equivalent to
  3. calling
  4. <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
  5. See {@link Hierarchy#resetConfiguration()} for more details. */
  6. public
  7. static
  8. void resetConfiguration() {
  9. LogManager.resetConfiguration();
  10. }
  11. }

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

  1. public static void updateLog4jConfiguration(Class<?> targetClass,
  2. String log4jPath) throws Exception {
  3. Properties customProperties = new Properties();
  4. FileInputStream fs = null;
  5. InputStream is = null;
  6. try {
  7. fs = new FileInputStream(log4jPath);
  8. is = targetClass.getResourceAsStream("/log4j.properties");
  9. customProperties.load(fs);
  10. Properties originalProperties = new Properties();
  11. originalProperties.load(is);
  12. for (Entry<Object, Object> entry : customProperties.entrySet()) {
  13. originalProperties.setProperty(entry.getKey().toString(), entry
  14. .getValue().toString());
  15. }
  16. LogManager.resetConfiguration();
  17. PropertyConfigurator.configure(originalProperties);
  18. }finally {
  19. IOUtils.closeQuietly(is);
  20. IOUtils.closeQuietly(fs);
  21. }
  22. }
  23. }

代码示例来源:origin: apache/incubator-gobblin

  1. /**
  2. * Update the log4j configuration.
  3. *
  4. * @param targetClass the target class used to get the original log4j configuration file as a resource
  5. * @param log4jFileName the custom log4j configuration properties file name
  6. * @throws IOException if there's something wrong with updating the log4j configuration
  7. */
  8. public static void updateLog4jConfiguration(Class<?> targetClass, String log4jFileName)
  9. throws IOException {
  10. final Closer closer = Closer.create();
  11. try {
  12. final InputStream inputStream = closer.register(targetClass.getResourceAsStream("/" + log4jFileName));
  13. final Properties originalProperties = new Properties();
  14. originalProperties.load(inputStream);
  15. LogManager.resetConfiguration();
  16. PropertyConfigurator.configure(originalProperties);
  17. } catch (Throwable t) {
  18. throw closer.rethrow(t);
  19. } finally {
  20. closer.close();
  21. }
  22. }
  23. }

代码示例来源:origin: apache/incubator-gobblin

  1. LogManager.resetConfiguration();
  2. PropertyConfigurator.configure(originalProperties);
  3. } catch (Throwable t) {

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

  1. @Before
  2. public void cleanupLoggers() {
  3. LogManager.resetConfiguration();
  4. }

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

  1. LogManager.resetConfiguration();

代码示例来源:origin: pentaho/pentaho-kettle

  1. private void applyLog4jConfiguration() {
  2. LogLog.setQuietMode( true );
  3. LogManager.resetConfiguration();
  4. LogLog.setQuietMode( false );
  5. /**
  6. * On DOMConfigurator.doConfigure() no exception is ever propagated; it's caught and its stacktrace is written to System.err.
  7. *
  8. * @link https://github.com/apache/log4j/blob/v1_2_17_rc3/src/main/java/org/apache/log4j/xml/DOMConfigurator.java#L877-L878
  9. *
  10. * When the kettle5-log4j-plugin is dropped under ~/.kettle/plugins ( which is also a valid location for classic pdi plugins )
  11. * we get a System.err 'FileNotFoundException' stacktrace, as this is attempting to fetch the log4j.xml under a (default path) of
  12. * data-integration/plugins/kettle5-log4j-plugin; but in this scenario ( again, a valid one ), kettle5-log4j-plugin is under ~/.kettle/plugins
  13. *
  14. * With the inability to catch any exception ( as none is ever propagated ), the option left is to infer the starting path of this plugin's jar;
  15. * - If it starts with Const.getKettleDirectory(): then we know it to have been dropped in ~/.kettle/plugins ( a.k.a. Const.getKettleDirectory() )
  16. * - Otherwise: fallback to default/standard location, which is under <pdi-install-dir>/</>data-integration/plugins
  17. */
  18. final String log4jPath = getPluginPath().startsWith( getKettleDirPath() )
  19. ? ( Const.getKettleDirectory() + File.separator + PLUGIN_PROPERTIES_FILE ) : getConfigurationFileName();
  20. DOMConfigurator.configure( log4jPath );
  21. }

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

  1. /**
  2. Reset the default hierarchy to its defaut. It is equivalent to
  3. calling
  4. <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
  5. See {@link Hierarchy#resetConfiguration()} for more details. */
  6. public
  7. static
  8. void resetConfiguration() {
  9. LogManager.resetConfiguration();
  10. }
  11. }

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

  1. /**
  2. Reset the default hierarchy to its defaut. It is equivalent to
  3. calling
  4. <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
  5. See {@link Hierarchy#resetConfiguration()} for more details. */
  6. public
  7. static
  8. void resetConfiguration() {
  9. LogManager.resetConfiguration();
  10. }
  11. }

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

  1. public static void updateLog4jConfiguration(Class<?> targetClass,
  2. String log4jPath) throws Exception {
  3. Properties customProperties = new Properties();
  4. FileInputStream fs = null;
  5. InputStream is = null;
  6. try {
  7. fs = new FileInputStream(log4jPath);
  8. is = targetClass.getResourceAsStream("/log4j.properties");
  9. customProperties.load(fs);
  10. Properties originalProperties = new Properties();
  11. originalProperties.load(is);
  12. for (Entry<Object, Object> entry : customProperties.entrySet()) {
  13. originalProperties.setProperty(entry.getKey().toString(), entry
  14. .getValue().toString());
  15. }
  16. LogManager.resetConfiguration();
  17. PropertyConfigurator.configure(originalProperties);
  18. }finally {
  19. IOUtils.closeQuietly(is);
  20. IOUtils.closeQuietly(fs);
  21. }
  22. }
  23. }

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

  1. @Before
  2. public void setup() throws Exception {
  3. // reset log4j
  4. LogManager.resetConfiguration();
  5. // initialize framework
  6. framework = new P6TestFramework("log4j") {
  7. };
  8. framework.setUpFramework();
  9. }

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

  1. protected void configure(String log4jConfSuffix, boolean removeDefaultExcludedCategories) throws Exception {
  2. if (removeDefaultExcludedCategories) {
  3. // we test slf4j filtering here rather than categories one
  4. P6LogOptions.getActiveInstance().setExcludecategories("");
  5. }
  6. // reset log4j
  7. LogManager.resetConfiguration();
  8. // configure log4j externally
  9. configureLog4JInTest(log4jConfSuffix);
  10. }

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

  1. @After
  2. public void cleanup() throws Exception {
  3. // restore default excluded categories
  4. P6LogOptions.getActiveInstance().setExcludecategories(
  5. StringUtils.join(P6TestOptionDefaults.DEFAULT_CATEGORIES, ","));
  6. framework.closeConnection();
  7. // reset log4j
  8. LogManager.resetConfiguration();
  9. // load default configuration
  10. configureLog4J();
  11. }

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

  1. /**
  2. * Shut down the Pax Logging service. This will reset the logging configuration entirely, so it should only be
  3. * used just before disposing of the service instance.
  4. */
  5. protected void shutdown() {
  6. LogManager.resetConfiguration();
  7. }

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

  1. /**
  2. Reset the default hierarchy to its defaut. It is equivalent to
  3. calling
  4. <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
  5. See {@link Hierarchy#resetConfiguration()} for more details. */
  6. public
  7. static
  8. void resetConfiguration() {
  9. LogManager.resetConfiguration();
  10. }
  11. }

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

  1. /**
  2. Reset the default hierarchy to its defaut. It is equivalent to
  3. calling
  4. <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
  5. See {@link Hierarchy#resetConfiguration()} for more details. */
  6. public
  7. static
  8. void resetConfiguration() {
  9. LogManager.resetConfiguration();
  10. }
  11. }

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

  1. /**
  2. Reset the default hierarchy to its defaut. It is equivalent to
  3. calling
  4. <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
  5. See {@link Hierarchy#resetConfiguration()} for more details. */
  6. public
  7. static
  8. void resetConfiguration() {
  9. LogManager.resetConfiguration();
  10. }
  11. }

代码示例来源:origin: org.apache.accumulo/accumulo-server

  1. private void resetLogger() {
  2. // Force a reset on the logger's configuration
  3. LogManager.resetConfiguration();
  4. new DOMConfigurator().doConfigure(filename, LogManager.getLoggerRepository());
  5. }

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

  1. @Override
  2. protected void setUp() throws Exception {
  3. super.setUp();
  4. LogFactory.getFactory().release();
  5. LogManager.resetConfiguration();
  6. }

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

  1. @Override
  2. protected void tearDown() throws Exception {
  3. LogFactory.getFactory().release();
  4. LogManager.resetConfiguration();
  5. super.tearDown();
  6. }

相关文章