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 Ashwin Bangalore <ar...@statestreet.com> on 2002/04/26 19:40:01 UTC

Log4j writes to multiple log files (Additivity problems?)

Hello Log4J Gurus,

I have a bit of a problem with Log4J writing into multiple log files.
I searched the mailing list for a similar problem/solution but I've
either missed it somewhere or didn't find an exact problem posted.
I did read the fine manual, How-to and the troubleshooting guide also.
*grin*

Let me explain a little about what I'm trying to do:
I have three classes GrandParent, Parent and Child. All three of them
are individually configured and write to their own log files.
The additivity of all the three are explicitly set to false.
The problem is that if the Child writes a log entry, the entry is written
to all the three log files - Child.log, Parent.log and GrandParent.log.

I know I'm goofing up somewhere in defining categories, but I just can't
figure out where. Can someone please help me troubleshooting this problem?

Will the fact that I have aliased MyFileAppender thrice play a part in
writing multiple times? I can give you more details about the extended
classes if anyone requires.

Pardon me if this has been answered before and kindly point me to
the correct resources.

Thanks for your help.

Ashwin.

My log4j.properties looks something like this:
============Begin Properties file=========================
log4j.appender.SyslogAppender=com.abc.sle.logging.SLESyslogAppender
log4j.appender.SyslogAppender.Threshold=FATAL

log4j.appender.default=com.abc.sle.logging.MyFileAppender
log4j.appender.GParentAppender=com.abc.sle.logging.MyFileAppender
log4j.appender.ParentAppender=com.abc.sle.logging.MyFileAppender
log4j.appender.ChildAppender=com.abc.sle.logging.MyFileAppender

log4j.appender.default.layout=org.apache.log4j.PatternLayout
log4j.appender.GParentAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ParentAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ChildAppender.layout=org.apache.log4j.PatternLayout

log4j.appender.default.layout.ConversionPattern=[%p] %d %m %n
log4j.appender.GParentAppender.layout.ConversionPattern=[%p] %d %m %n
log4j.appender.ParentAppender.layout.ConversionPattern=[%p] %d %m %n
log4j.appender.ChildAppender.layout.ConversionPattern=[%p] %d %m %n

log4j.appender.default.Append=true
log4j.appender.GParentAppender.Append=true
log4j.appender.ParentAppender.Append=true
log4j.appender.ChildAppender.Append=true

log4j.appender.default.File=default.log
log4j.appender.GParentAppender.File=GParent.log
log4j.appender.ParentAppender.File=Parent.log
log4j.appender.ChildAppender.File=Child.log

log4j.category.default=DEBUG, default, SyslogAppender
log4j.category.GParent=DEBUG, GParentAppender, SyslogAppender
log4j.category.Parent=DEBUG, ParentAppender, SyslogAppender
log4j.category.Child.DEBUG, ChildAppender, SyslogAppender

log4j.additivity.category.default=false
log4j.additivity.category.GParentAppender=false
log4j.additivity.category.ParentAppender=false
log4j.additivity.category.ChildAppender=false

====================== End Properties File =======================

Notes:
MyFileAppender is a simple extension of org.apache.log4j.FileAppender
SyslogAppender is a simple extension of AppenderSkeleton. Calls a custom
Syslog API also written in Java.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4j writes to multiple log files (Additivity problems?)

Posted by Krishna srinivasan <ja...@yahoo.co.uk>.
I'm faced with a similar situation.

I need to log error and fatal in a separate log file
while debug, info and warn in another file. Is this
possible ?

I tried with creating a different apenders but does'nt
seem to work.
Any suggestions?





--- Ashwin Bangalore <ar...@statestreet.com>
wrote:
> Scott,
> Thanks so much. That solution definitely helped.
> I had probably picked up that line from a bad sample
> properties
> file.
> Cheers,
> Ashwin.
> 
> -----Original Message-----
> From: Scott Farquhar [mailto:scott@atlassian.com]
> Sent: Friday, April 26, 2002 8:19 PM
> To: Log4J Users List
> Subject: Re: Log4j writes to multiple log files
> (Additivity problems?)
> 
> 
> This line:
> 
> log4j.additivity.category.default=false
> 
> should be this instead:
> 
> log4j.additivity.default=false
> 
> Similar for the other additivity lines.
> 
> 
> Cheers,
> Scott
> 
> Ashwin Bangalore wrote:
> > Hello Log4J Gurus,
> > 
> > I have a bit of a problem with Log4J writing into
> multiple log files.
> > I searched the mailing list for a similar
> problem/solution but I've
> > either missed it somewhere or didn't find an exact
> problem posted.
> 
> << Snipped >>
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4J with IPlanet

Posted by Dave Bender <da...@benders-of-edina.com>.
Bryan,

I'm not familiar with kregedit. I'm referring to the web-based GUI interface
iPlanet has for configuring the servers.

Dave


-----Original Message-----
From: bryan hansen [mailto:bh5k@yahoo.com]
Sent: Tuesday, April 30, 2002 1:48 PM
To: Log4J Users List
Subject: RE: Log4J with IPlanet


Do you mean under kregedit?

I am not totally clear what you mean by:
it's in Server
Manager->Java->Configure
JVM Attributes.

Bryan

--- Dave Bender <da...@benders-of-edina.com> wrote:
> You need to put the log4j.jar file in the iPlanet
> classpath for that
> particular server instance. In v6.0, it's in Server
> Manager->Java->Configure
> JVM Attributes.
>
> Also if you're working in Windows and Unix, you need
> to remember that the
> classpath in Unix is separated by : not ;.  iPlanet
> doesn't complain if you
> get it wrong. I did. Took a while to figure it out.
>
>
> Dave
>
>
> -----Original Message-----
> From: bryan hansen [mailto:bh5k@yahoo.com]
> Sent: Tuesday, April 30, 2002 12:34 PM
> To: Log4J Users List; arbangalore@statestreet.com
> Subject: Log4J with IPlanet
>
>
> I am using log4j with Iplanet. When I go to package
> up
> my application it says that it can not resolve the
> some of the log4j classes. I realize this is
> probably
> a packaging issue with iPlanet, but was wondering it
> anybody else has ran into this and if not how do you
> package your applications with Iplanet and log4j to
> avoid this?
>
> Thanks,
>
> Bryan
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4J with IPlanet

Posted by bryan hansen <bh...@yahoo.com>.
Do you mean under kregedit?

I am not totally clear what you mean by:
it's in Server
Manager->Java->Configure
JVM Attributes.

Bryan

--- Dave Bender <da...@benders-of-edina.com> wrote:
> You need to put the log4j.jar file in the iPlanet
> classpath for that
> particular server instance. In v6.0, it's in Server
> Manager->Java->Configure
> JVM Attributes.
> 
> Also if you're working in Windows and Unix, you need
> to remember that the
> classpath in Unix is separated by : not ;.  iPlanet
> doesn't complain if you
> get it wrong. I did. Took a while to figure it out.
> 
> 
> Dave
> 
> 
> -----Original Message-----
> From: bryan hansen [mailto:bh5k@yahoo.com]
> Sent: Tuesday, April 30, 2002 12:34 PM
> To: Log4J Users List; arbangalore@statestreet.com
> Subject: Log4J with IPlanet
> 
> 
> I am using log4j with Iplanet. When I go to package
> up
> my application it says that it can not resolve the
> some of the log4j classes. I realize this is
> probably
> a packaging issue with iPlanet, but was wondering it
> anybody else has ran into this and if not how do you
> package your applications with Iplanet and log4j to
> avoid this?
> 
> Thanks,
> 
> Bryan
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


passing an URL to configureAndWatch ?

Posted by Anjan Bacchu <an...@bluewireless.com>.
Hi All,

	Thanks to all Log4j implementors.

	Is there a way I can call PropertyConfigurator.configureAndWatch() without
passing a file name ?

	Actually, I have a web app which is in the form of a WAR file and the
Property file in in the
WEB-INF\classes directory. How do I get the name of the file ?
It would be useful if I could pass an URL (URL =
ClassLoader.getResource("debug.ini") ) ?

Thank you,

Best Regards,
ANJAN. B


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4J with IPlanet

Posted by Dave Bender <da...@benders-of-edina.com>.
You need to put the log4j.jar file in the iPlanet classpath for that
particular server instance. In v6.0, it's in Server Manager->Java->Configure
JVM Attributes.

Also if you're working in Windows and Unix, you need to remember that the
classpath in Unix is separated by : not ;.  iPlanet doesn't complain if you
get it wrong. I did. Took a while to figure it out.


Dave


-----Original Message-----
From: bryan hansen [mailto:bh5k@yahoo.com]
Sent: Tuesday, April 30, 2002 12:34 PM
To: Log4J Users List; arbangalore@statestreet.com
Subject: Log4J with IPlanet


I am using log4j with Iplanet. When I go to package up
my application it says that it can not resolve the
some of the log4j classes. I realize this is probably
a packaging issue with iPlanet, but was wondering it
anybody else has ran into this and if not how do you
package your applications with Iplanet and log4j to
avoid this?

Thanks,

Bryan

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Log4J with IPlanet

Posted by bryan hansen <bh...@yahoo.com>.
I am using log4j with Iplanet. When I go to package up
my application it says that it can not resolve the
some of the log4j classes. I realize this is probably
a packaging issue with iPlanet, but was wondering it
anybody else has ran into this and if not how do you
package your applications with Iplanet and log4j to
avoid this?

Thanks,

Bryan

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Log4j writes to multiple log files (Additivity problems?)

Posted by Ashwin Bangalore <ar...@statestreet.com>.
Scott,
Thanks so much. That solution definitely helped.
I had probably picked up that line from a bad sample properties
file.
Cheers,
Ashwin.

-----Original Message-----
From: Scott Farquhar [mailto:scott@atlassian.com]
Sent: Friday, April 26, 2002 8:19 PM
To: Log4J Users List
Subject: Re: Log4j writes to multiple log files (Additivity problems?)


This line:

log4j.additivity.category.default=false

should be this instead:

log4j.additivity.default=false

Similar for the other additivity lines.


Cheers,
Scott

Ashwin Bangalore wrote:
> Hello Log4J Gurus,
> 
> I have a bit of a problem with Log4J writing into multiple log files.
> I searched the mailing list for a similar problem/solution but I've
> either missed it somewhere or didn't find an exact problem posted.

<< Snipped >>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Log4j writes to multiple log files (Additivity problems?)

Posted by Scott Farquhar <sc...@atlassian.com>.
This line:

log4j.additivity.category.default=false

should be this instead:

log4j.additivity.default=false

Similar for the other additivity lines.


Cheers,
Scott

Ashwin Bangalore wrote:
> Hello Log4J Gurus,
> 
> I have a bit of a problem with Log4J writing into multiple log files.
> I searched the mailing list for a similar problem/solution but I've
> either missed it somewhere or didn't find an exact problem posted.
> I did read the fine manual, How-to and the troubleshooting guide also.
> *grin*
> 
> Let me explain a little about what I'm trying to do:
> I have three classes GrandParent, Parent and Child. All three of them
> are individually configured and write to their own log files.
> The additivity of all the three are explicitly set to false.
> The problem is that if the Child writes a log entry, the entry is written
> to all the three log files - Child.log, Parent.log and GrandParent.log.
> 
> I know I'm goofing up somewhere in defining categories, but I just can't
> figure out where. Can someone please help me troubleshooting this problem?
> 
> Will the fact that I have aliased MyFileAppender thrice play a part in
> writing multiple times? I can give you more details about the extended
> classes if anyone requires.
> 
> Pardon me if this has been answered before and kindly point me to
> the correct resources.
> 
> Thanks for your help.
> 
> Ashwin.
> 
> My log4j.properties looks something like this:
> ============Begin Properties file=========================
> log4j.appender.SyslogAppender=com.abc.sle.logging.SLESyslogAppender
> log4j.appender.SyslogAppender.Threshold=FATAL
> 
> log4j.appender.default=com.abc.sle.logging.MyFileAppender
> log4j.appender.GParentAppender=com.abc.sle.logging.MyFileAppender
> log4j.appender.ParentAppender=com.abc.sle.logging.MyFileAppender
> log4j.appender.ChildAppender=com.abc.sle.logging.MyFileAppender
> 
> log4j.appender.default.layout=org.apache.log4j.PatternLayout
> log4j.appender.GParentAppender.layout=org.apache.log4j.PatternLayout
> log4j.appender.ParentAppender.layout=org.apache.log4j.PatternLayout
> log4j.appender.ChildAppender.layout=org.apache.log4j.PatternLayout
> 
> log4j.appender.default.layout.ConversionPattern=[%p] %d %m %n
> log4j.appender.GParentAppender.layout.ConversionPattern=[%p] %d %m %n
> log4j.appender.ParentAppender.layout.ConversionPattern=[%p] %d %m %n
> log4j.appender.ChildAppender.layout.ConversionPattern=[%p] %d %m %n
> 
> log4j.appender.default.Append=true
> log4j.appender.GParentAppender.Append=true
> log4j.appender.ParentAppender.Append=true
> log4j.appender.ChildAppender.Append=true
> 
> log4j.appender.default.File=default.log
> log4j.appender.GParentAppender.File=GParent.log
> log4j.appender.ParentAppender.File=Parent.log
> log4j.appender.ChildAppender.File=Child.log
> 
> log4j.category.default=DEBUG, default, SyslogAppender
> log4j.category.GParent=DEBUG, GParentAppender, SyslogAppender
> log4j.category.Parent=DEBUG, ParentAppender, SyslogAppender
> log4j.category.Child.DEBUG, ChildAppender, SyslogAppender
> 
> log4j.additivity.category.default=false
> log4j.additivity.category.GParentAppender=false
> log4j.additivity.category.ParentAppender=false
> log4j.additivity.category.ChildAppender=false
> 
> ====================== End Properties File =======================
> 
> Notes:
> MyFileAppender is a simple extension of org.apache.log4j.FileAppender
> SyslogAppender is a simple extension of AppenderSkeleton. Calls a custom
> Syslog API also written in Java.
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 


-- 
Scott Farquhar :: scott@atlassian.com

Atlassian :: http://www.atlassian.com
      Supporting YOUR J2EE World



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>