You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Alan Robertson <ar...@mail.infonow.com> on 2001/04/17 20:05:29 UTC
feedback from DOMConfigurator configuration?
Ceki, et al:
I'm wondering if there is any way to determine if the DOMConfigurator
was successfully configured or not? The configure() and
configureAndWatch() methods only return void and not a boolean and they
don't even throw exceptions if they have a problem, right? So they
offer no feedback as to whether they were sucessful or not.
Would it be possible to add a method that returns a boolean indicating
whether the DOMConfigurator is configured or not? Maybe called
something like isConfigured()? That would be easier than changing the
configure methods to return a boolean.
The reason I need this is so I can determine if an attempt at
configuring the DOMConfigurator was sucessful or not. If it is not
sucessful then I will fall back to using the BasicConfigurator and
provide feedback to the user that the DOM didn't work.
Thanks,
Alan
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org
Re: feedback from DOMConfigurator configuration?
Posted by Alan Robertson <ar...@mail.infonow.com>.
Hmmmmm, good question.
I guess all I really want to know is whether the DOMConfigurator has created an appender for the root category or not. If it hasn't then I'll call BasicConfigurator.configure().
Now, after looking at the javadocs a little, it looks like I can do this:
DOMConfigurator.configureAndWatch(configFile);
Category root = Category.getRoot();
Enumeration rootAppend = root.getAllAppenders();
if ((rootAppend == null) || (!rootAppend.hasMoreElements())) {
BasicConfigurator.configure();
}
I tested this and it works the way I expect. The only thing I'll point out is a possible documentation error. In the javadoc for Category it states the following for the method getAllAppenders(): "Get the appenders contained in this category as an Enumeration. If there are no
appenders in this category null is returned." This isn't entirely true. It is possible to get back an Enumeration with no elements. Thus the check in my code using 'hasMoreElements()'.
Thanks,
Alan
Ceki Gülcü wrote:
> Alan,
>
> The semantics of isConfigured() is far from being clear. What happens if a config file has hundreds of lines containing just one mistake. The DOMConfigurator will emit a warning about the erroneous line and happily configure log4j according to the rest (correct) config file.
>
> What should isConfigured() return in that case? Ceki
>
> At 12:05 17.04.2001 -0600, Alan Robertson wrote:
> >Ceki, et al:
> >
> >I'm wondering if there is any way to determine if the DOMConfigurator
> >was successfully configured or not? The configure() and
> >configureAndWatch() methods only return void and not a boolean and they
> >don't even throw exceptions if they have a problem, right? So they
> >offer no feedback as to whether they were sucessful or not.
> >
> >Would it be possible to add a method that returns a boolean indicating
> >whether the DOMConfigurator is configured or not? Maybe called
> >something like isConfigured()? That would be easier than changing the
> >configure methods to return a boolean.
> >
> >The reason I need this is so I can determine if an attempt at
> >configuring the DOMConfigurator was sucessful or not. If it is not
> >sucessful then I will fall back to using the BasicConfigurator and
> >provide feedback to the user that the DOM didn't work.
> >
> >Thanks,
> >Alan
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
> --
> Ceki Gülcü
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
Re: feedback from DOMConfigurator configuration?
Posted by Ceki Gülcü <cg...@qos.ch>.
Alan,
The semantics of isConfigured() is far from being clear. What happens if a config file has hundreds of lines containing just one mistake. The DOMConfigurator will emit a warning about the erroneous line and happily configure log4j according to the rest (correct) config file.
What should isConfigured() return in that case? Ceki
At 12:05 17.04.2001 -0600, Alan Robertson wrote:
>Ceki, et al:
>
>I'm wondering if there is any way to determine if the DOMConfigurator
>was successfully configured or not? The configure() and
>configureAndWatch() methods only return void and not a boolean and they
>don't even throw exceptions if they have a problem, right? So they
>offer no feedback as to whether they were sucessful or not.
>
>Would it be possible to add a method that returns a boolean indicating
>whether the DOMConfigurator is configured or not? Maybe called
>something like isConfigured()? That would be easier than changing the
>configure methods to return a boolean.
>
>The reason I need this is so I can determine if an attempt at
>configuring the DOMConfigurator was sucessful or not. If it is not
>sucessful then I will fall back to using the BasicConfigurator and
>provide feedback to the user that the DOM didn't work.
>
>Thanks,
>Alan
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
--
Ceki Gülcü
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org