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

Issue while configuring Tomcat default log and log4j

 
Sourav DasXx
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm very new to Java/Tomcat.

I'm using Apache Tomcat 7.0.47 in Windows 7 machine.

I am using log4j in my web application - MyApps and don't want to use log4j for Tomcat's internal logging. I have only kept log4j.jar and log4j.properties into WEB-INF/lib and WEB-INF/classes of my web application. No other modification in Tomcat's configuration. But, Tomcat is using log4j to log its internal information.

I want Tomcat to use java.util.logging (default) for its internal logging and my web application - MyApps to use log4j. Please advise where I am going wrong.

---------------------------
Best Regards
Sourav Das
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18218
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Sourav!

The logging used by Tomcat itself and the logging used by webapps are completely independent of each other, to the point that the logging system used by one webapp can be completely different from any other deployed webapp.

Except for cases where you've done a custom build of the Tomcat server itself, Tomcat will be using java.util.logging (juli) as its logger.

System.out.println statements executed from a webapp will appear in the catalina.out file, which is the usual place of the Tomcat server log, but they won't actually be going through the logging system, just routed to stdout, which, since it's also the default Tomcat juli log destination means that the 2 types of print (juli and System.out) will intermingle in the catalina.out logfile.

The original servlet spec had a logging method, which actually was pretty limited. As far as I know, it routes to Tomcat's System.out or juli logger, but it's better not to use it if your webapp is using a real logger like log4j or juli.

In short, you shouldn't be seeing the problem you claim you're seeing, since what you want is the normal way that Tomcat and webapps log.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic