aspose file tools*
The moose likes Java in General and the fly likes Log4j tw0 appenders problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Log4j tw0 appenders problem" Watch "Log4j tw0 appenders problem" New topic
Author

Log4j tw0 appenders problem

Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

Hi Folks ,

I have two logging appenders like
log4j.appender.application = org.apache.log4j.RollingFileAppender
log4j.appender.sql = org.apache.log4j.RollingFileAppender

log4j.logger.com.infy=INFO, application
log4j.logger.com.infy.dao=INFO, sql

question is that in sql appenders i can see the sql debug statements
and the same can also been seen in application appenders also , i suspect because com.infy is superclass for com.infy.dao
it logs

what i need is what sql appenders logs , the same log i should not log in application appender
how can i dot that .
Please do help or suggest


Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
You might want to read on the concept of "additivity" in Log4J.

Checkout the Appenders and Layout section of this page.


SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

Hi Paul ,

Thanks a lot .

Issue had been fixed with writing these lines

log4j.category.com.infy.dao=INFO, sql
log4j.additivity.com.infy.dao=false
Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
You're most welcome.
Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
Before I forget, you might want to use the XML format for configuration instead of the properties file.

It is easier to read in my opinion and there are certain things you cannot do with the properties file which can only be done using XML config.

i.e. Setting up filters (if I remember correctly from the The Complete Log4j Manual book)

Hope this helps.
[ May 07, 2008: Message edited by: Paul Michael ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j tw0 appenders problem