Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Answers

Does Tomcat have built-in logging capabilities, and if so how do I use them?

...

Wiki Markup
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.

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?

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.

How do I configure commons-logging for use with Tomcat?

...

  • Wiki Markup
    \[http://markmail.org/message/3fjakrf77dqmy5nz Where are the Tomcat logs when running as a Windows service?\]
    \\

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:

Wiki Markup
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/.