Also, it is programmatically possible to check if Log4j has been configured previously, thus avoiding the problem (which may or may not help in this particular case). My development team creates components used throughout our enterprise, and if an application has configured Log4j, we want to avoid configuring it ourselves and instead piggy-back off their configuration. If not, then we of course need to configure Log4j independently. We always check first to see if Log4j has been configured, and if and only if it has not, do we actually configure it at run-time.
The code to check if Log4j has been configured follows: public static boolean isConfigured() { java.util.Enumeration enum = Logger.getRoot().getAllAppenders(); if ((enum != null) && (!(enum instanceof org.apache.log4j.helpers.NullEnumeration))) { return true; } else { java.util.Enumeration loggers = org.apache.log4j.LogManager.getCurrentLoggers() ; while (loggers.hasMoreElements()) { Logger c = (Logger) loggers.nextElement(); if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration)) return true; } } return false; } -----Original Message----- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 9:18 AM To: Log4J Users List Subject: RE: calling DOMConfigurator.configureAndWatch() 2 times Howdy, >What should happen if the configureAndWatch() function is called twice? >Are the previous settings erased? Are they accumulated ? It wouldn't be that hard to simply test this and see what happens ;) But looking at the code, you see: - configureAndWatch always creates a new XMLWatchdog, so you will have two XMLWatchdogs watching over the file. - Each XMLWatchdog would call DOMConfigurator#doConfigure(filename, repository) when the file changes, so this method will get called twice. So this is extra overhead that should be avoided if possible. - The configuration file will get parsed again with a new parser - Parsing will replace where found and add where not found. So if there's already a logger for class, for example, it will be retrieved if it exists and reconfigured, or a new one will be created if one doesn't exist. You can walk through the rest of DOMConfigurator if you feel like it ;) This is one issue where the test is easy so I wouldn't even spend time looking at the code ;) Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ------------------------------------------------------------------------------- This message and any included attachments are from Siemens Medical Solutions USA, Inc. and are intended only for the addressee(s). The information contained herein may include trade secrets or privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you received this message in error, or have reason to believe you are not authorized to receive it, please promptly delete this message and notify the sender by e-mail with a copy to [EMAIL PROTECTED] Thank you --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]