tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Tomcat Wiki] Update of "HowTo" by KonstantinKolinko
Date Fri, 29 Jul 2011 23:11:24 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for change notification.

The "HowTo" page has been changed by KonstantinKolinko:
http://wiki.apache.org/tomcat/HowTo?action=diff&rev1=107&rev2=108

Comment:
Correct some typos. Update "system properties" tip.

  == How do I load a properties file? ==
  Here are the three most popular ways::
  
-  * Use a classloader's getResource to get an url to the properties file and load it into
the Properties. The properties file must be located within the webapp classpath (i.e. either
WEB-INF/classes/... or in a jar.
+  * Use a classloader's getResource to get an url to the properties file and load it into
the Properties. The properties file must be located within the webapp classpath (i.e. either
{{{WEB-INF/classes/...}}} or in a jar in {{{WEB-INF/lib/}}}).
  
  A challenge is to get the classloader when you are in a static initializer:
  
@@ -67, +67 @@

  p.load(is);
  is.close();
  }}}
+ 
  == How do I log requests ? ==
  See AccessLogValve
  
  == Can I set Java system properties differently for each webapp? ==
- No.  If you can edit Tomcat's startup scripts, you can add "-D" options to Java.  But there
is no way to add such properties in web.xml or the webapp's context.
+ No.  If you can edit Tomcat's startup scripts (or better create a {{{setenv.sh}}} file),
you can add "-D" options to Java.  But there is no way in Java to have different values of
system properties for different classes in the same JVM.
+ 
+ There are some other methods available, like using {{{ServletContext.getContextPath()}}}
to get the context name of your web application and locate some resources accordingly, or
to define {{{<context-param>}}} elements in {{{WEB-INF/web.xml}}} file of your web application
and then set the values for them in Tomcat context file ({{{META-INF/context.xml}}}). See
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html .
  
  == How do I use log4j for all Tomcat log output? ==
  To have Tomcat use log4j universally, place both `log4j.jar` and the Jakarta `commons-logging.jar`
into the `$TOMCAT_HOME/common/lib` directory.  Create your log4j properties file as `$TOMCAT_HOME/common/classes/log4j.properties`
and configure the root logger.  Here is the basic `log4j.properties` that I used to do this
myself:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message