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 Ionel GARDAIS <ig...@yahoo.fr> on 2004/01/26 13:31:44 UTC

multiple logger to the same appender

Hi,

Is it possible for many loggers to use the same
appender ?

I know a single logger can log to multiple appender
but is the reverse true ?

Another question : when setting additivity to false,
what is the behavior when multiple appenders are
declared for the logger ?

Thanks,
ionel

_________________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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


Re: multiple logger to the same appender

Posted by Ionel GARDAIS <ig...@yahoo.fr>.
Yes it is

But I was not thinkning of a programmatically created
logger.

Say I have this :

log4j.rootLogger=DEBUG, A1, mailer
log4j.logger.aClass=DEBUG, A2, mailer

log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.file=TEProxy.log
log4j.appender.A1.append=false
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t]
%-5p %c - %m%n

log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.file=PerfPublisher.log
log4j.appender.A2.append=false
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d [%t]
%-5p %c - %m%n

log4j.appender.mailer=org.apache.log4j.net.SMTPAppender
log4j.appender.mailer.from=ionel.gardais@sgcib.com
log4j.appender.mailer.to=ionel.gardais@sgcib.com
log4j.appender.mailer.subject=TEProxy
log4j.appender.mailer.SMTPHost=smtp-gw
log4j.appender.mailer.bufferSize=5
log4j.appender.mailer.layout=org.apache.log4j.PatternLayout
log4j.appender.mailer.layout.ConversionPattern=%d [%t]
%-5p %c - %m%n


Is it correct ?

the RootLogger and the aClass logger have their own
FileAppender and they both refer to the mailer
SMTPAppender (so they merge log message to the mailer
appender)

this is what I meant.

ionel

> I incurred in a similar doubt lately. Supose you are
> configuring your 
> logger programmatically. So you can create an
> appender, create a logger, 
> and set the appender to that logger.  In the case
> you are creating more 
> than one logger, it may be interesting (but I'm no
> sure yet...) to reuse 
> the same appender, so that making changes in one
> configuration, will 
> reflect on ALL the loggers that use it.
> 
> Ionel, is this your case?


_________________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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


Re: multiple logger to the same appender

Posted by Jorge Francisco Del Teglia <jo...@acm.org>.
Hi,

>> Hi,
>>
>> Is it possible for many loggers to use the same
>> appender ?
>>
>> I know a single logger can log to multiple appender
>> but is the reverse true ?
>
>
> I don't understand the question.  Appenders don't declare loggers, 
> loggers declare appenders and loggers can specify multiple appenders.  
> What functionality are you looking for that you don't feel is already 
> covered by this scenario?
>
I incurred in a similar doubt lately. Supose you are configuring your 
logger programmatically. So you can create an appender, create a logger, 
and set the appender to that logger.  In the case you are creating more 
than one logger, it may be interesting (but I'm no sure yet...) to reuse 
the same appender, so that making changes in one configuration, will 
reflect on ALL the loggers that use it.

Ionel, is this your case?

>> Another question : when setting additivity to false,
>> what is the behavior when multiple appenders are
>> declared for the logger ?
>
>
> Same as always.  The only difference is that the logger with 
> additivity="false" doesn't inherit appenders declared for parent 
> loggers, but will log to any and all appenders declared for itself.
>
> Jake
>
>> Thanks,
>> ionel
>>

Jorge




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


Re: multiple logger to the same appender

Posted by Jacob Kjome <ho...@visi.com>.
At 01:31 PM 1/26/2004 +0100, you wrote:
>Hi,
>
>Is it possible for many loggers to use the same
>appender ?
>
>I know a single logger can log to multiple appender
>but is the reverse true ?

I don't understand the question.  Appenders don't declare loggers, loggers 
declare appenders and loggers can specify multiple appenders.  What 
functionality are you looking for that you don't feel is already covered by 
this scenario?

>Another question : when setting additivity to false,
>what is the behavior when multiple appenders are
>declared for the logger ?

Same as always.  The only difference is that the logger with 
additivity="false" doesn't inherit appenders declared for parent loggers, 
but will log to any and all appenders declared for itself.

Jake

>Thanks,
>ionel
>


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