logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Question on logger hierarchy
Date Wed, 08 Sep 2004 17:00:17 GMT

On Sep 8, 2004, at 7:38 AM, Robert Haschke wrote:

> Dear developers,
> I'm new to log4* and I'm wondering how I can achieve the following 
> goal:
> I want to have a top level logger, logging to cerr with a level 
> Below may be several other loggers with their own appenders, layouts 
> and
> logging levels. If I trigger an error or warning on these descendant
> loggers, the message (if enabled at all) should be forwarded to the
> top-level logger, logging to cerr. I think, this is the purpose of the
> logger hierarchy.
> My attempt to this failed, because all messages enabled at the
> descendant loggers are forwarded to its ancestors, which do not check
> the log level anymore. Why should this behaviour be useful?

It allows you to lower the threshold of a specific child logger while 
suppressing all other loggers.  It is an established log4j behavior and 
not subject to change.  The scenario is discussed in the section 
"Setting the level of a logger" (pg 55) of "The complete manual log4j", 
but I didn't see it discussed online.

> Why should I
> use a logger hierarchy, if I cannot influence the logging through the
> different log levels?
> How can I achive my goal?

You should be able to set the threshold on the appender attached to the 
root logger.

> In future releases, it would be very convenient to have logger methods,
> which allow printf-like formatting.

I'd like to keep the LOG4CXX_level macros as simple as possible (and 
simpler than they are now).  I don't think printf is desirable since so 
many had things can happen if the format specifiers don't match the 
arguments.  However, making it simple to do logging involving 
operator<< is a worthwhile goal, something like:

LOG4CXX_DEBUG_STREAM(logger, "The current count is " << count);

which would be equivalent to something like:

LOG4CXX_DEBUG(logger, ((std::ostringstream)()  << The current count is 
" << count).str());

View raw message