wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes log4j and tomcat 6.x problem - not writing to the log files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j and tomcat 6.x problem - not writing to the log files" Watch "log4j and tomcat 6.x problem - not writing to the log files" New topic
Author

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

Srikanth Madasu
Ranch Hand

Joined: Sep 10, 2008
Posts: 48

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...


If it's easy.. then everybody would do it!
Srikanth Madasu
Ranch Hand

Joined: Sep 10, 2008
Posts: 48

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

Joined: Jun 24, 2003
Posts: 3274
    
    5

You don't need to have both log4j.properties and log4j.xml, you should just stick with one (log4.xml being preferred).


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Srikanth Madasu
Ranch Hand

Joined: Sep 10, 2008
Posts: 48

Thanks for your reply.. but that did not really make any difference

Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I think you might be missing something from your xml configuration, here's a sanmple of what I use:


Srikanth Madasu
Ranch Hand

Joined: Sep 10, 2008
Posts: 48

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

Joined: Jun 24, 2003
Posts: 3274
    
    5

Glad you got it working!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j and tomcat 6.x problem - not writing to the log files
 
Similar Threads
Unable to get logging working in Tomcat application
log4j.xml configuration for configuring input from specific file only to consider logging.
How to hide/disable Hibernate log to console
log4j - email
log4j with xml config file