Here is some code that Ceki sent out earlier. Might need some updating to use the latest 1.2 classes. It should be noted that this code will not detect if errors occured during configuration. At least for DOMConfigurator, errors do not cause it to abort the entire configuration action.
-Mark /** Returns true if it appears that log4j have been previously configured. This code (from Ceki Gülcü) checks to see if there are any appenders defined for log4j which is the definitive way to tell if log4j is already initialized */ private static boolean isConfigured() { Enumeration enum = Category.getRoot().getAllAppenders(); if (!(enum instanceof org.apache.log4j.helpers.NullEnumeration)) { return true; } else { Enumeration cats = Category.getCurrentCategories(); while (cats.hasMoreElements()) { Category c = (Category) cats.nextElement(); if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration)) return true; } } return false; } > -----Original Message----- > From: doug b [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 15, 2002 10:44 AM > To: Log4J Developers List > Subject: Re: boolean Configurator.isConfigured() > > > that would be nice. what we did instead was: > > Enumeration iterator = > Category.getRoot().getAllAppenders(); > if (!iterator.hasMoreElements()) > { > BasicConfigurator.configure(); > } > > --- Endre_Stølsvik <[EMAIL PROTECTED]> wrote: > > A method for asking whether the log4j system is > > configured would be nice. > > Is it there already? > > > > It would be great for driver/testing classes, as one > > could have a block > > such as: > > > > static { > > if (! Configurator.isConfigred() ) { > > BasicConfigurator.configure(); > > } > > } > > > > -- > > Mvh, > > Endre > > > > > > > > -- > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Tax Center - online filing with TurboTax > http://taxes.yahoo.com/ > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>