• 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

using log4j in Tomcat

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use log4j to trace any debig information in my application.However since it is my first time to use log4j I got some problem. Suppose my appication is in the path c:\tomcat\webapps\catania-web Since we all know I need a file to config my log4j.Let us say the file is called simplelog.properties.I put this file under the folder c:\tomcat\webapps\catania-web\WEB-INF. I put all my settings in the web.xml as follows:
<context-param>
<param-name>LogConfig</param-name>
<param-value>cataniaLog.properties</param-value>
</context-param>
So I can trigger this parameter by getServletContext().
The problem is that I do not know how to set the <param-value> tag so that my application can find my properties file. My current approach is to use the absolute path i.e. <param-value>c:/tomcat/webapps/catania-web/WEB-INF/cataniaLog.properties</param-value>. But I know it is not a good idea to put absolute path here. Could anybody tell me how to write a abstract path and where should I put my simplelog.properties thanks in advance
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can put the log4j.properties for server level (used by the container) in $CATALINA_HOME/common/classes (or anywhere on the classpath of tomcat); this will regulate all debug messages coming from the classloader of tomcat itself.

For each web application you can put the log4j.properties in the WEB-INF/classes directory. You can explicitly instantiate properties file like you say, but it is not necessary.
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic