logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Bender" <d...@benders-of-edina.com>
Subject RE: newbie: trouble making sub category log differently
Date Tue, 02 Apr 2002 22:51:22 GMT
Thanks Dan. It was your BTW note that set me straight. I had transposed the
domain name in the configuration file. Now it's working as advertised. It
seems like a great logging package, so I'm anxious to get into it.

Dave



-----Original Message-----
From: Dan Lipofsky [mailto:danlip@nuserve.com]
Sent: Tuesday, April 02, 2002 4:11 PM
To: log4j-user@jakarta.apache.org
Subject: Re: newbie: trouble making sub category log differently


> I must be missing something obvious, but I cannot get a Category of mine
to
> log to a location other than that of the rootCategory. Can someone point
out
> what I'm missing?
>
> The behaviour I'd like is for all loggers to output to a file, except for
> one category, which should log to the console. I've defined "A1" and "A2"
as
> my appenders and both are functional, in that if I assign the root
category
> to go there, everything goes where it's instructed to go.
>
> But if I assign my category, umn.edu.cidrap.admin.ContentBean, to use one
or
> the other or both, it doesn't. The output goes where the rootCategory is
> defined to go.
>
> Any help would be appreciated. I think I've covered all the documentation,
> but if it's there, I'm not seeing it.

Everything inherits from root unless you tell it otherwise.
With your setup umn.edu.cidrap.admin.ContentBean will
go to both A1 and A2.  To stop this turn additivity off, like

log4j.additivity.umn.edu.cidrap.admin.ContentBean = false

It is in the manual.  Inheritance is very well documented and
a key feature of log4j.  Additivity flag is pretty obscure but it is
in the docs.

BTW, since you are in the umn.edu domain you should be naming
your packages like edu.umn.
- Dan

> # define which appenders to use for our categories/loggers
> log4j.rootCategory=DEBUG, A1
> log4j.category.umn.edu.cidrap.admin.ContentBean=, A2
>
>
> # A1 is set to be a ConsoleAppender which outputs to System.out.
> log4j.appender.A2=org.apache.log4j.ConsoleAppender
>
> log4j.appender.A1=org.apache.log4j.FileAppender
> log4j.appender.A1.File=log4j-test.log
>
>
> # A1 uses PatternLayout; so does A2
> log4j.appender.A1.layout=org.apache.log4j.PatternLayout
> log4j.appender.A2.layout=org.apache.log4j.PatternLayout
>
> # The conversion pattern uses format specifiers. Both the same.
> log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
> log4j.appender.A2.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n



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



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


Mime
View raw message