Dear Wiki user,

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

The following page has been changed by ole:
http://wiki.apache.org/tomcat/FAQ/Logging

------------------------------------------------------------------------------
  
  == Questions ==
   1. [#Q1 Does Tomcat have built-in logging capabilities, and if so how do I 
use them?]
+  1. [#Q2 What role does commons-logging play in logging?]
+  1. [#Q3 What role does JULI and log4j play in logging?]
-  1. [#Q2 How do I configure commons-logging for use with Tomcat?]
+  1. [#Q4 How do I configure commons-logging for use with Tomcat?]
-  1. [#Q3 How should I log in my own webapps?]
+  1. [#Q5 How should I log in my own webapps?]
-  1. [#Q4 Where does System.out go? How do I rotate catalina.out?]
+  1. [#Q6 Where does System.out go? How do I rotate catalina.out?]
-  1. [#Q5 Where are the logs when running Tomcat as a Windows service?]
+  1. [#Q7 Where are the logs when running Tomcat as a Windows service?]
+  1. [#Q8 How do I customize the location of the tomcat logging.properties 
file?]
  
  == Answers ==
  
@@ -30, +33 @@

  
  In addition, Tomcat does not swallow the System.out and System.err JVM output 
streams. You may use these streams for elementary logging if you wish, but a 
more robust approach such as commons-logging or 
[http://logging.apache.org/log4j Log4J] is recommended for production 
applications.
  
+ 
+ 
+ [[Anchor(Q2)]]'''What role does commons-logging play in logging?'''
+ 
+ Tomcat wants to support multiple logging implementations, so it uses 
commons-logging.
+ In case that's unclear, think of it like this.  You are a Tomcat developer.  
The car
+ you drive when logging is the commons-logging car.  The engine of that car is 
either
+ JULI or log4j.  Without one of these engines, the car goes no where.  However 
regardless
+ of whether you use JULI or log4j, the steering wheel, break, gas pedal, etc. 
are the same. 
+ 
+ Related FAQ:
+ What role does JULI and log4j play in logging?
+ 
+ [[Anchor(Q3)]]'''What role does JULI and log4j play in logging?'''
+ 
+ First see:
+ What role does commons-logging play in logging?
+ 
+ Note in addition that in your own applications you could log directly
+ with JULI or log4j.  But once you choose one, you can't easily switch
+ to the other later.  If you use commons-logging you can.
+ 
- [[Anchor(Q2)]]'''How do I configure commons-logging for use with Tomcat?'''
+ [[Anchor(Q4)]]'''How do I configure commons-logging for use with Tomcat?'''
  
  You need to specify a commons-logging configuration file and, if you wish, a 
logging implementation that supports commons-logging. JDK 1.4 (and later) 
java.util.Logging and Log4j are the two most commonly used logging toolkits for 
Tomcat. If you supply an external logging toolkit such as Log4J, it needs to be 
located in the $CATALINA_HOME/common/lib directory (for Tomcat 5.0 and earlier) 
or added to the bootstrap classpath by using the scripts in $CATALINA_HOME/bin 
(this is required for Tomcat 5.5 and later, which uses commons-logging while 
bootstrapping, and optional for Tomcat 5.0 and earlier).
  
@@ -41, +66 @@

   * [http://marc.theaimsgroup.com/?l=tomcat-user&m=108578233003073&w=2 Example 
with JSVC and running on port 80.]
   * [http://markmail.org/message/3sgxfol3njcfutsm Need for it to be in 
bootstrap classpath.]
  
- [[Anchor(Q3)]]'''How should I log in my own webapps?'''
+ [[Anchor(Q5)]]'''How should I log in my own webapps?'''
  
  While you can use System.out and System.err to log, we strongly recommend 
using a toolkit like Log4J or JDK 1.4's java.util.logging package. With these 
toolkits, you have significantly more functionality (for example, sending 
emails, logging to a database, controlling at runtime the logging level of 
different classes, inspecting the logs with a graphical viewer, etc.) than with 
Tomcat's built-in default logging configuration.
  
  We also recommend that you separate your logging from Tomcat's internal 
logging. That means you should bundle your logging toolkit with your webapp. If 
you're using Log4J, for example, place the Log4J jar in the WEB-INF/lib 
directory of your webapp and the Log4J configuration file in the 
WEB-INF/classes directory of your webapp. This way different web applications 
can have different logging configurations and you don't need to worry about 
them interfering with each other.
  
- [[Anchor(Q4)]]'''Where does System.out go? How do I rotate catalina.out?'''
+ [[Anchor(Q6)]]'''Where does System.out go? How do I rotate catalina.out?'''
  
  System.out and System.err both print to catalina.out. But you can suppress 
this via the swallowOutput property and sent to different log files.
  catalina.out does not rotate. But it should not be an issue because nothing 
should be printing to standard output since you are using a logging package, 
right? [http://marc.theaimsgroup.com/?t=105544472600001&r=1&w=2a thread about 
rotation of catalina.out]
  
- [[Anchor(Q5)]]'''Where are the logs when running Tomcat as a Windows 
service?'''
+ [[Anchor(Q7)]]'''Where are the logs when running Tomcat as a Windows 
service?'''
  
  See these mailing list archive threads:
  
   * [http://markmail.org/message/3fjakrf77dqmy5nz Where are the Tomcat logs 
when running as a Windows service?]
  
+ [[Anchor(Q8)]]'''How do I customize the location of the tomcat 
logging.properties file?'''
+ 
+ Set the following property when starting tomcat:
+ 
+ java.util.logging.config.file
+ 
+ Example:
+ -Djava.util.logging.config.file=/etc/tomcat/logging.properties
+ 
+ For another example of how to set this look in catalina.sh for 
+ Tomcat 6.0.16 on lines 182-185.  The statements look like this:
+ 
+ 182 # Set juli LogManager if it is present
+ if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then
+    JAVA_OPTS="$JAVA_OPTS 
"-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" 
"-Djava.util.logging.config.file="$CATALINA_BASE/conf/    logging.properties"
+ fi
+ 
+ Projects such as JPackage that repackage Tomcat for Linux typically
+ move the configuration to a directory dictated by the FHS standard
+ (http://www.pathname.com/fhs/), and therefore use the 
java.util.logging.config.file
+ property to set the location of the logging.properties file in the Tomcat
+ startup script.
+ 
+ On Fedora this script in typically located in /etc/rc.d/init.d/ and on
+ Gentoo linux it is located in /etc/init.d/.
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to