File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Issue while configuring Tomcat default log and log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Issue while configuring Tomcat default log and log4j" Watch "Issue while configuring Tomcat default log and log4j" New topic

Issue while configuring Tomcat default log and log4j

Sourav DasXx

Joined: May 14, 2014
Posts: 1
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 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

Joined: Jun 25, 2001
Posts: 17417

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Issue while configuring Tomcat default log and log4j
It's not a secret anymore!