• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issue while configuring Tomcat default log and log4j

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic