/** Reset the default hierarchy to its defaut. It is equivalent to calling <code>Category.getDefaultHierarchy().resetConfiguration()</code>. See {@link Hierarchy#resetConfiguration()} for more details. */ public static void resetConfiguration() { LogManager.resetConfiguration(); } }
public static void updateLog4jConfiguration(Class<?> targetClass, String log4jPath) throws Exception { Properties customProperties = new Properties(); FileInputStream fs = null; InputStream is = null; try { fs = new FileInputStream(log4jPath); is = targetClass.getResourceAsStream("/log4j.properties"); customProperties.load(fs); Properties originalProperties = new Properties(); originalProperties.load(is); for (Entry<Object, Object> entry : customProperties.entrySet()) { originalProperties.setProperty(entry.getKey().toString(), entry .getValue().toString()); } LogManager.resetConfiguration(); PropertyConfigurator.configure(originalProperties); }finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(fs); } } }
/** * Update the log4j configuration. * * @param targetClass the target class used to get the original log4j configuration file as a resource * @param log4jFileName the custom log4j configuration properties file name * @throws IOException if there's something wrong with updating the log4j configuration */ public static void updateLog4jConfiguration(Class<?> targetClass, String log4jFileName) throws IOException { final Closer closer = Closer.create(); try { final InputStream inputStream = closer.register(targetClass.getResourceAsStream("/" + log4jFileName)); final Properties originalProperties = new Properties(); originalProperties.load(inputStream); LogManager.resetConfiguration(); PropertyConfigurator.configure(originalProperties); } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } } }
LogManager.resetConfiguration(); PropertyConfigurator.configure(originalProperties); } catch (Throwable t) {
@Before public void cleanupLoggers() { LogManager.resetConfiguration(); }
LogManager.resetConfiguration();
private void applyLog4jConfiguration() { LogLog.setQuietMode( true ); LogManager.resetConfiguration(); LogLog.setQuietMode( false ); /** * On DOMConfigurator.doConfigure() no exception is ever propagated; it's caught and its stacktrace is written to System.err. * * @link https://github.com/apache/log4j/blob/v1_2_17_rc3/src/main/java/org/apache/log4j/xml/DOMConfigurator.java#L877-L878 * * When the kettle5-log4j-plugin is dropped under ~/.kettle/plugins ( which is also a valid location for classic pdi plugins ) * we get a System.err 'FileNotFoundException' stacktrace, as this is attempting to fetch the log4j.xml under a (default path) of * data-integration/plugins/kettle5-log4j-plugin; but in this scenario ( again, a valid one ), kettle5-log4j-plugin is under ~/.kettle/plugins * * 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; * - If it starts with Const.getKettleDirectory(): then we know it to have been dropped in ~/.kettle/plugins ( a.k.a. Const.getKettleDirectory() ) * - Otherwise: fallback to default/standard location, which is under <pdi-install-dir>/</>data-integration/plugins */ final String log4jPath = getPluginPath().startsWith( getKettleDirPath() ) ? ( Const.getKettleDirectory() + File.separator + PLUGIN_PROPERTIES_FILE ) : getConfigurationFileName(); DOMConfigurator.configure( log4jPath ); }
/** Reset the default hierarchy to its defaut. It is equivalent to calling <code>Category.getDefaultHierarchy().resetConfiguration()</code>. See {@link Hierarchy#resetConfiguration()} for more details. */ public static void resetConfiguration() { LogManager.resetConfiguration(); } }
/** Reset the default hierarchy to its defaut. It is equivalent to calling <code>Category.getDefaultHierarchy().resetConfiguration()</code>. See {@link Hierarchy#resetConfiguration()} for more details. */ public static void resetConfiguration() { LogManager.resetConfiguration(); } }
public static void updateLog4jConfiguration(Class<?> targetClass, String log4jPath) throws Exception { Properties customProperties = new Properties(); FileInputStream fs = null; InputStream is = null; try { fs = new FileInputStream(log4jPath); is = targetClass.getResourceAsStream("/log4j.properties"); customProperties.load(fs); Properties originalProperties = new Properties(); originalProperties.load(is); for (Entry<Object, Object> entry : customProperties.entrySet()) { originalProperties.setProperty(entry.getKey().toString(), entry .getValue().toString()); } LogManager.resetConfiguration(); PropertyConfigurator.configure(originalProperties); }finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(fs); } } }
@Before public void setup() throws Exception { // reset log4j LogManager.resetConfiguration(); // initialize framework framework = new P6TestFramework("log4j") { }; framework.setUpFramework(); }
protected void configure(String log4jConfSuffix, boolean removeDefaultExcludedCategories) throws Exception { if (removeDefaultExcludedCategories) { // we test slf4j filtering here rather than categories one P6LogOptions.getActiveInstance().setExcludecategories(""); } // reset log4j LogManager.resetConfiguration(); // configure log4j externally configureLog4JInTest(log4jConfSuffix); }
@After public void cleanup() throws Exception { // restore default excluded categories P6LogOptions.getActiveInstance().setExcludecategories( StringUtils.join(P6TestOptionDefaults.DEFAULT_CATEGORIES, ",")); framework.closeConnection(); // reset log4j LogManager.resetConfiguration(); // load default configuration configureLog4J(); }
/** * Shut down the Pax Logging service. This will reset the logging configuration entirely, so it should only be * used just before disposing of the service instance. */ protected void shutdown() { LogManager.resetConfiguration(); }
/** Reset the default hierarchy to its defaut. It is equivalent to calling <code>Category.getDefaultHierarchy().resetConfiguration()</code>. See {@link Hierarchy#resetConfiguration()} for more details. */ public static void resetConfiguration() { LogManager.resetConfiguration(); } }
/** Reset the default hierarchy to its defaut. It is equivalent to calling <code>Category.getDefaultHierarchy().resetConfiguration()</code>. See {@link Hierarchy#resetConfiguration()} for more details. */ public static void resetConfiguration() { LogManager.resetConfiguration(); } }
/** Reset the default hierarchy to its defaut. It is equivalent to calling <code>Category.getDefaultHierarchy().resetConfiguration()</code>. See {@link Hierarchy#resetConfiguration()} for more details. */ public static void resetConfiguration() { LogManager.resetConfiguration(); } }
private void resetLogger() { // Force a reset on the logger's configuration LogManager.resetConfiguration(); new DOMConfigurator().doConfigure(filename, LogManager.getLoggerRepository()); }
@Override protected void setUp() throws Exception { super.setUp(); LogFactory.getFactory().release(); LogManager.resetConfiguration(); }
@Override protected void tearDown() throws Exception { LogFactory.getFactory().release(); LogManager.resetConfiguration(); super.tearDown(); }