This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
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 ]
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

Hi Paul ,

This is age old application i cant all of the sudden change the log4j.properties to log4j.xml

i think we can even create the own level and configure in log4j.properties
i did too it worked ( adding the threshold LEVEL#className).

even i need google to find the advantages of using xml over properties file

Thanks a lot
 
Consider Paul's rocket mass heater.
 
subject: Log4j tw0 appenders problem
 
Similar Threads
Log4j in Eclipse Vs Log4j Outside Eclipse
Log4j tw0 appenders problem
Different Appender for each level
log4j writing to multiple log
thread safe logging in a servlet