Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j and tomcat 6.x problem - not writing to the log files

 
Srikanth Madasu
Ranch Hand
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am planning to have two separate log files for different packages - one for app and other for daos.

I am using following log4j.xml



I am using following log4j.properties file




And in my class in ex.com.app package I am using
private static Logger log = Logger.getLogger(LogonAction.class);

And in my class in ex.com.dao package I am using
private static Logger log = Logger.getLogger(LogonDAOImpl.class);

I am deploying the application on tomcat 6.x and I made sure that I have log4j.dtd, log4j.xml & log4j.prop file in the classpath WEB-Inf/classes/

It is creating the log files in the location I specified but it is never writing into these files.

Am I missing something or are there any configuration that are specific to tomcat? please help!!

thanks in advance...
 
Srikanth Madasu
Ranch Hand
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried a sample java proj in eclipse sing same code, and it worked fine.

So I am guessing it has to do something with the tomcat configuration.

Did anyone successfully used log4j on tomcat server? please help!!!

 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to have both log4j.properties and log4j.xml, you should just stick with one (log4.xml being preferred).
 
Srikanth Madasu
Ranch Hand
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.. but that did not really make any difference

 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you might be missing something from your xml configuration, here's a sanmple of what I use:


 
Srikanth Madasu
Ranch Hand
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Its now working. I used the following code. I am posting it so that it may be useful to other.




Thanks a bunch for your help!!!
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you got it working!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic