logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Glezen" <pgle...@us.ibm.com>
Subject RE: Adding isConfigured method to LoggerRepository interface
Date Fri, 30 Aug 2002 15:02:50 GMT

We could have the isConfigured() method take as a parameter the Category
name (errr sorry, the Logger name).  This would remove some of the
ambiguity.  I realize people just want to know whether it's configured, not
realizing that "it depends".

Perhaps isConfigured(String loggerName) could check the configuration of
loggerName.  If loggerName is null or empty, then it performs as you
describe below.

- Paul

Paul Glezen
Consulting IT Specialist
IBM Software Services for WebSphere
818 539 3321


Ceki Gülcü <ceki@qos.ch> on 08/30/2002 07:03:50 AM

Please respond to "Log4J Developers List" <log4j-dev@jakarta.apache.org>

To:    "Log4J Developers List" <log4j-dev@jakarta.apache.org>, "'Log4J
       Developers List'" <log4j-dev@jakarta.apache.org>
cc:
Subject:    RE: Adding isConfigured method to LoggerRepository interface




What is the definition of "log4j is configured"? Is it when a
configurator is invoked? When the first appender is attached to the
root logger? Any logger? Is it when the level of a logger is set?

One possible definition is to say that log4j is considered as
configured when the "log4j:WARN: No appenders could be found for
logger (xyz)" message no longer appears.

Given the tree-like structure of logger hierarchies, this message
depends on the logger. For example, assuming nothing is attached to
the root logger, if you attach an appender to logger "x", then loggers
"x", "x.y" and "x.y.z" will be considered as configured whereas logger
"a.b.c" cannot be considered as configured.

Based on the "log4j.WARN: No appenders ..." criteria, a logger is
considered as configured if a FATAL message sent to that logger will
not print the "log4j.WARN: ..."  message. This will happen if the
logger's effective level is OFF or if an appender is attached to the
logger or higher up in the tree.

Does it make sense?

At 09:46 28.08.2002 -0700, Mark Womack wrote:
>+1 to this concept, but does it have to be dependent on some code
>(configurator or user) calling a setConfigured() method?  Is there anyway
>for this value to be set when code starts manipulating the logger/appender
>settings?
>
>-Mark
>
> > -----Original Message-----
> > From: Ceki Gülcü [mailto:ceki@qos.ch]
> > Sent: Wednesday, August 28, 2002 7:22 AM
> > To: log4j-dev@jakarta.apache.org
> > Subject: Adding isConfigured method to LoggerRepository interface
> >
> >
> >
> > In the past, developers have often complained about the difficulties
> > of determining whether log4j has been already configured. One possible
> > way is to check whether the root logger has been configured. For
> > example,
> >
> > Logger root = Logger.getRootLogger();
> > boolean rootIsConfigured = root.getAllAppenders().hasMoreElements();
> >
> > The slight problem with this technique is that log4j may be configured
> > without this being visible at the root logger level.
> >
> > I propose that in log4j 1.2.7 we add the isConfigured method
> > (returning a boolean) in to the LoggerRepository interface. Users
> > would then write
> >
> > LogManager.getLoggerRepository().isConfigured()
> >
> > to check whether log4j was already configured or not.
> >
> > Existing configurators would call loggerRepository.setConfigured(true)
> > when configuring log4j. User code would also have the possibility to
> > call this method.
> >
> > --
> > Ceki
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:log4j-dev-help@jakarta.apache.org>
> >
>
>--
>To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org
>
>For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org
>

--
Ceki


--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>






--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>


Mime
View raw message