John Volkar wrote:
>
> Ahem, just a quick one.
>
> Becareful if using this code as it's not quite right. The
> .getAllAppenders() method does NOT seem to return null if there are no
> appenders on the root category (like the javadocs say it should). It seems
> to return an instance of a log4j.helpers.NullEnumeration class instead.
>
> Maybe someone should patch the javadocs please. (Maybe this is just for the
> Root category, though? hmmm)
No it's all Categories. I've removed the offending comment. Thanks.
>
> Regards
>
> John Volkar
>
> -----Original Message-----
> From: Anders Kristensen [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 30, 2001 8:17 AM
> To: LOG4J Users Mailing List
> Subject: Re: PropertyConfigurator question
>
> Andy Kriger wrote:
> > [...]
> > What I want is a way to check if PropertyConfigurator is able to find
> > log4j.properties and if not, then and only then call
> > BasicConfigurator.configure() as a backup.
> >
> > Is this possible?
>
> You can check whether at least one Category has been added to the
> default hierarchy or whether an appender has been added to the root
> category:
>
> public static boolean isLog4jConfigured() {
> Enumeration cats = Category.getCurrentCategories();
> Enumeration rootApps = Category.getRoot().getAllAppenders();
> return cats.hasMoreElements() || rootApps != null;
> }
>
> I haven't checked it but it ought to work.
>
> <<-SNIP->>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Anders Kristensen
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]