vmassol 01/08/14 05:15:48 Modified: cactus/src/framework/share/org/apache/commons/cactus/util/log LogService.java Log: corrected bug reported by GUMP (thanks GUMP!) when initializing the logging system with a null parameter passed to LogService.init() Revision Changes Path 1.4 +23 -8 jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/LogService.java Index: LogService.java =================================================================== RCS file: /home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/LogService.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LogService.java 2001/06/27 20:44:41 1.3 +++ LogService.java 2001/08/14 12:15:48 1.4 @@ -117,18 +117,33 @@ * Initialize the logging system. Need to be called once before calling * <code>getLog()</code>. * - * @param theFileName the file name (Ex: "/log_client.properties") + * @param theFileName the file name (Ex: "/log_client.properties") or null + * to initialize a dummy logging system, meaning that all log calls + * will have no effect. This is useful for unit testing for + * instance where the goal is not to verify that logs are printed. */ public void init(String theFileName) { - if (isLog4jInClasspath) { + // If logging system already initialized, do nothing + if (isInitialized()) { + return; + } - URL url = this.getClass().getResource(theFileName); - if (url != null) { - // Initialize Log4j - PropertyConfigurator.configure(url); - } else { - throw new RuntimeException("Could not find [" + theFileName + "]"); + if (theFileName != null) { + + if (isLog4jInClasspath) { + + URL url = this.getClass().getResource(theFileName); + if (url != null) { + // Initialize Log4j + PropertyConfigurator.configure(url); + } else { + // Failed to configure logging system, simply print + // a warning on stderr + System.err.println("Failed to configure logging " + + "system : Could not find file [" + theFileName + "]"); + } + } }