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 ); }
public static void setupLogging(String application) throws UnknownHostException { System.setProperty("org.apache.accumulo.core.application", application); if (System.getenv("ACCUMULO_LOG_DIR") != null) System.setProperty("org.apache.accumulo.core.dir.log", System.getenv("ACCUMULO_LOG_DIR")); else System.setProperty("org.apache.accumulo.core.dir.log", System.getenv("ACCUMULO_HOME") + "/logs/"); String localhost = InetAddress.getLocalHost().getHostName(); System.setProperty("org.apache.accumulo.core.ip.localhost.hostname", localhost); // Use a specific log config, if it exists String logConfigFile = locateLogConfig(System.getenv("ACCUMULO_CONF_DIR"), application); // Turn off messages about not being able to reach the remote logger... we protect against that. LogLog.setQuietMode(true); // Set up local file-based logging right away Log4jConfiguration logConf = new Log4jConfiguration(logConfigFile); logConf.resetLogger(); }
LogLog.setQuietMode(true);