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 "Stephen Chell (DSL AK)" <St...@datacom.co.nz> on 2004/02/29 23:15:08 UTC

Log4j: appender specific logging levels?

Hi all,

 

I'm new to log4j.  I know what I want to achieve, but the most intuitive way
of achieving it doesn't seem possible with the current release of log4j.  

 

The design goals I have are as follows:

1. Name loggers by software component.  ie statically instantiate a logger
in each class, with the logger name equal to the fully qualified name of the
class.

2. Output logging to one or two files, depending on configuration (see next
two points).

3. Output to the first file will always be enabled, and will include all
messages logged with a priority of INFO or higher.  

4. Output to the second file (used for debugging purposes) will be enabled
on an ad-hoc basis, and will include all messages regardless of priority.
The layout used for this file will be different to the first file.  (eg
class name will only be printed in the debug file.) 

 

It would seem that the most intuitive way to configure this would be to
configure two different appenders for the Root logger, with each appender
having its own message priority level and layout.  However, as I understand
it the priority level can only be set by logger, not appender.

 

Any suggestions on how to satisfy the above design goals?

 

Thanks in advance ...

 

Steve

 


Re: Log4j: appender specific logging levels?

Posted by Paul Smith <pa...@lawlex.com.au>.
> It would seem that the most intuitive way to configure this would be to
> configure two different appenders for the Root logger, with each
> appender
> having its own message priority level and layout.  However, as I
> understand
> it the priority level can only be set by logger, not appender.
> 
>  
> 
> Any suggestions on how to satisfy the above design goals?

If you use the XML configuration file, you can define a Filter which
filters by level.  You would then set the Logger's Level to ALL, and
specify the levels you want in each Appender you attach.

See the Wiki:

http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/FrequentlyAskedQuestions

In particular the Log By Level one.

cheers,

Paul Smith


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org