Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log4j tw0 appenders problem

 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to read on the concept of "additivity" in Log4J.

Checkout the Appenders and Layout section of this page.
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're most welcome.
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic