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 Adam Creeger <ad...@gmail.com> on 2010/10/20 23:23:20 UTC

Is it possible to configure different log levels for the same appender based on what logger it is coming from?

Hello all,

I have a question regarding how I might configure Log4J to support the
following scenario:

The root logger has an appender (let's call this Appender Z) with a
threshold of INFO. There is some important "info" messages that get logged
to that root logger, so we can't set the threshold any higher...

Logger A has some verbose "info" logging that we wish to log to a separate
appender (Appender Y). We want Logger A's "warn" and "error" messages to
appear in the root logger, but not Logger A's "info" messages. It is totally
fine for Logger A's "warn" and "error" messages to appear in Appender Y.

If I set additivity to false on Logger A, none of its "warn" or "error"
messages will make it to Appender Z. If I leave additivity as true, all of
its "info" messages will appear in Appender Z, which is not what we want.

Is there something I'm missing here?

Thanks!

Adam

RE: [SCL-4] Is it possible to configure different log levels for the same appender based on what logger it is coming from?

Posted by Bender Heri <hb...@ergonomics.ch>.
One possibility I see:
Write an own Filter which is attached to the root logger's Apender and filter out the messages which you do not want.
Heri

> -----Original Message-----
> From: Adam Creeger [mailto:adamcreeger@gmail.com]
> Sent: Wednesday, October 20, 2010 11:23 PM
> To: log4j-user@logging.apache.org
> Subject: [SCL-4] Is it possible to configure different log levels for the same appender based on what
> logger it is coming from?
> 
> Hello all,
> 
> I have a question regarding how I might configure Log4J to support the
> following scenario:
> 
> The root logger has an appender (let's call this Appender Z) with a
> threshold of INFO. There is some important "info" messages that get logged
> to that root logger, so we can't set the threshold any higher...
> 
> Logger A has some verbose "info" logging that we wish to log to a separate
> appender (Appender Y). We want Logger A's "warn" and "error" messages to
> appear in the root logger, but not Logger A's "info" messages. It is totally
> fine for Logger A's "warn" and "error" messages to appear in Appender Y.
> 
> If I set additivity to false on Logger A, none of its "warn" or "error"
> messages will make it to Appender Z. If I leave additivity as true, all of
> its "info" messages will appear in Appender Z, which is not what we want.
> 
> Is there something I'm missing here?
> 
> Thanks!
> 
> Adam

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


Re: Is it possible to configure different log levels for the same appender based on what logger it is coming from?

Posted by Adam Creeger <ad...@gmail.com>.
Hi Ceki,

Thanks for responding so quickly! Yes, we do have access to the source
code... (But we'd rather address this via configuration than code changes)

Adam

On 20 October 2010 14:39, Ceki Gülcü <ce...@qos.ch> wrote:

> Hello Adam,
>
> Do you have access to the source code where logger A is defined and used?
>
> --
> Ceki - http://logback.qos.ch/
>
>
> On 20/10/2010 11:23 PM, Adam Creeger wrote:
>
>> Hello all,
>>
>> I have a question regarding how I might configure Log4J to support the
>> following scenario:
>>
>> The root logger has an appender (let's call this Appender Z) with a
>> threshold of INFO. There is some important "info" messages that get logged
>> to that root logger, so we can't set the threshold any higher...
>>
>> Logger A has some verbose "info" logging that we wish to log to a separate
>> appender (Appender Y). We want Logger A's "warn" and "error" messages to
>> appear in the root logger, but not Logger A's "info" messages. It is
>> totally
>> fine for Logger A's "warn" and "error" messages to appear in Appender Y.
>>
>> If I set additivity to false on Logger A, none of its "warn" or "error"
>> messages will make it to Appender Z. If I leave additivity as true, all of
>> its "info" messages will appear in Appender Z, which is not what we want.
>>
>> Is there something I'm missing here?
>>
>> Thanks!
>>
>> Adam
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Is it possible to configure different log levels for the same appender based on what logger it is coming from?

Posted by Ceki Gülcü <ce...@qos.ch>.
Hello Adam,

Do you have access to the source code where logger A is defined and used?

--
Ceki - http://logback.qos.ch/

On 20/10/2010 11:23 PM, Adam Creeger wrote:
> Hello all,
>
> I have a question regarding how I might configure Log4J to support the
> following scenario:
>
> The root logger has an appender (let's call this Appender Z) with a
> threshold of INFO. There is some important "info" messages that get logged
> to that root logger, so we can't set the threshold any higher...
>
> Logger A has some verbose "info" logging that we wish to log to a separate
> appender (Appender Y). We want Logger A's "warn" and "error" messages to
> appear in the root logger, but not Logger A's "info" messages. It is totally
> fine for Logger A's "warn" and "error" messages to appear in Appender Y.
>
> If I set additivity to false on Logger A, none of its "warn" or "error"
> messages will make it to Appender Z. If I leave additivity as true, all of
> its "info" messages will appear in Appender Z, which is not what we want.
>
> Is there something I'm missing here?
>
> Thanks!
>
> Adam
>


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