Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 36D837525 for ; Wed, 3 Aug 2011 23:30:07 +0000 (UTC) Received: (qmail 52645 invoked by uid 500); 3 Aug 2011 23:30:06 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 52447 invoked by uid 500); 3 Aug 2011 23:30:05 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 52438 invoked by uid 99); 3 Aug 2011 23:30:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 23:30:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,MANY_SUBDOM X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 23:30:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0BFD523889B2 for ; Wed, 3 Aug 2011 23:29:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1153703 - in /tomcat/tc6.0.x/trunk/webapps/docs: changelog.xml logging.xml Date: Wed, 03 Aug 2011 23:29:42 -0000 To: dev@tomcat.apache.org From: kkolinko@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110803232943.0BFD523889B2@eris.apache.org> Author: kkolinko Date: Wed Aug 3 23:29:41 2011 New Revision: 1153703 URL: http://svn.apache.org/viewvc?rev=1153703&view=rev Log: CTR: Docs Update logging documentation 1. Place a better note that Log4J configuration is not needed if it is only osed by one's webapp. 2. Rearrange Log4J configuration section and document how configure it to be used by a single CATALINA_BASE only. 3. Add "productive usage considerations" subsection to JULI one. Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml tomcat/tc6.0.x/trunk/webapps/docs/logging.xml Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1153703&r1=1153702&r2=1153703&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Wed Aug 3 23:29:41 2011 @@ -297,7 +297,8 @@ (markt) - Improve Tomcat Logging documentation. (kkolinko) + Improve class loading documentation and logging documentation. + (kkolinko) Configure Security Manager How-To to include a copy of the actual @@ -336,9 +337,6 @@ (markt) - Improve class loading documentation. (kkolinko) - - Update documentation to be even more explicit about the implications of setting the path attribute on a Context element in server.xml. (markt/kkolinko) Modified: tomcat/tc6.0.x/trunk/webapps/docs/logging.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/logging.xml?rev=1153703&r1=1153702&r2=1153703&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/logging.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/logging.xml Wed Aug 3 23:29:41 2011 @@ -85,7 +85,7 @@ by the system and is shared across web applications.

- +

Apache Tomcat has its own implementation of several key elements of @@ -367,10 +367,10 @@ java.util.logging.ConsoleHandler.formatt

- +

See the following resources for additional information:

    -
  • Tomcat Javadoc for the +
  • Apache Tomcat Javadoc for the org.apache.juli package.
  • @@ -381,6 +381,26 @@ java.util.logging.ConsoleHandler.formatt
+ +

You may want to take note of the following:

+
    +
  • Consider removing ConsoleHandler from configuration.

    +

    By default (thanks to the .handlers setting) logging goes + both to a FileHandler and to a ConsoleHandler. + The output of the latter one is usually captured into a file, such as + catalina.out. Thus you end up with two copies of the same + messages.

    +
  • +
  • Consider removing FileHandlers for the applications + that you do not use. E.g., the one for host-manager.

  • +
  • The handlers by default use the system default encoding to write + the log files. It can be configured with encoding property. + See Javadoc for details.

  • +
  • Consider configuring an Access + log.

  • +
+
+
@@ -389,29 +409,22 @@ java.util.logging.ConsoleHandler.formatt log4j rather than java.util.logging for all Tomcat's internal logging.

-

Note, that

-
    -
  • This exposes log4j libraries to the web applications through the - Common classloader. See class loading - for details. The web applications using - Apache Commons Logging - library are likely to automatically choose log4j as the underlying - logging implementation.
  • -
  • The java.util.logging API is still available, for - those who use it directly. Removal of the - ${catalina.base}/conf/logging.properties file, mentioned - as one of the steps below, causes it to fallback to the default - configuration configured in JRE, which is to use a ConsoleHandler and - do not create any files.
  • -
+

Note: The steps described in this section are needed + when you want to reconfigure Tomcat to use Apache log4j for its own + logging. These steps are not needed if you just want + to use log4j in your own web application. — In that case, just + put log4j.jar and log4j.properties into + WEB-INF/lib and WEB-INF/classes + of your web application. +

The following steps describe configuring log4j to output Tomcat's internal logging.

    -
  1. Create a file called log4j.properties with the following content - and save it into $CATALINA_HOME/lib.
  2. +
  3. Create a file called log4j.properties with the + following content and save it into $CATALINA_BASE/lib
log4j.rootLogger=INFO, CATALINA @@ -464,25 +477,61 @@ log4j.logger.org.apache.catalina.core.Co
  1. Download Log4J - (v1.2 or later) and place the log4j jar in $CATALINA_HOME/lib.
  2. + (v1.2 or later). + +
  3. Download or build tomcat-juli.jar and + tomcat-juli-adapters.jar that are available as an "extras" + component for Tomcat. See Additional Components + documentation for details.

    +

    This tomcat-juli.jar differs from the default one. It + contains the full Apache Commons Logging implementation and thus is + able to discover the presense of log4j and configure itself.

    +
  4. + +
  5. If you want to configure Tomcat to use log4j globally:

    +
      +
    • Put log4j.jar into $CATALINA_HOME/lib.
    • +
    • Replace $CATALINA_HOME/bin/tomcat-juli.jar with + tomcat-juli.jar from "extras".
    • +
    • Put tomcat-juli-adapters.jar from "extras" into + $CATALINA_HOME/lib
    • +
    +
  6. + +
  7. If you are running Tomcat with separate $CATALINA_HOME and + $CATALINA_BASE and want to configure to use log4j in a single + $CATALINA_BASE only:

    +
      +
    • Create $CATALINA_BASE/bin and + $CATALINA_BASE/lib directories if they do not exist. +
    • +
    • Put log4j.jar into $CATALINA_BASE/lib
    • +
    • Put tomcat-juli.jar from "extras" as + $CATALINA_BASE/bin/tomcat-juli.jar
    • +
    • Put tomcat-juli-adapters.jar from "extras" into + $CATALINA_BASE/lib
    • +
    • If you are running with a + security manager, you + would need to edit the + $CATALINA_BASE/conf/catalina.policy file to adjust + it to using a different copy of tomcat-juli.jar.
    • +
    • The old tomcat-juli.jar in + $CATALINA_HOME/bin is still referenced by manifest of + bootstrap.jar and thus will be implicitly present + on Tomcat's classpath. The startup scripts configure + $CATALINA_BASE/bin/tomcat-juli.jar to be earlier on the + classpath than bootstrap.jar, and so it should have + higher priority. Thus it should be OK, but + consider removing the unneeded copy of tomcat-juli.jar + (copy it into all other $CATALINA_BASEs that do not use log4j). + Tomcat 7 does not have this issue.
    • +
    +
  8. + +
  9. Delete $CATALINA_BASE/conf/logging.properties to + prevent java.util.logging generating zero length log files.

  10. -
  11. Build or download the additional logging components. See the - extras components documentation for - details.
  12. - -
  13. Replace $CATALINA_HOME/bin/tomcat-juli.jar with - output/extras/tomcat-juli.jar.
  14. - -
  15. Place output/extras/tomcat-juli-adapters.jar in - $CATALINA_HOME/lib.
    - Note, that tomcat-juli.jar and - tomcat-juli-adapters.jar go into different - directories. While the first one goes into bin, this - one goes into lib.
  16. - -
  17. Delete $CATALINA_BASE/conf/logging.properties to - prevent java.util.logging generating zero length log files.
  18. -
  19. Start Tomcat
  20. +
  21. Start Tomcat

@@ -491,7 +540,7 @@ log4j.logger.org.apache.catalina.core.Co individual log file, and everything else goes to the "catalina.log" log file. Each file is rolled-over once per day.

- +

You can (and should) be more picky about which packages to include in the logging. Tomcat defines loggers by Engine and Host names. @@ -500,18 +549,19 @@ log4j.logger.org.apache.catalina.core.Co using this naming convention (with square brackets) in log4j XML based configuration files, so we recommend you use a properties file as described until a future version of log4j allows this convention. - +

log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG
log4j.logger.org.apache.catalina.core=DEBUG
log4j.logger.org.apache.catalina.session=DEBUG
- Be warned a level of DEBUG will produce megabytes of logging and slow +

+ Be warned: a level of DEBUG will produce megabytes of logging and slow startup of Tomcat. This level should be used sparingly when debugging of internal Tomcat operations is required.

- +

Your web applications should certainly use their own log4j configuration. This is valid with the above configuration. You would place a @@ -524,20 +574,26 @@ log4j.logger.org.apache.catalina.session bootstrapping guide.

-

- If you have multiple instances of Tomcat, each with a separate - $CATALINA_BASE but a shared $CATALINA_HOME then - you can configure log4j on a per instance basis by replacing references to - $CATALINA_HOME in the above instructions with - $CATALINA_BASE. Note that if you do this then you may need to - make some, or all, of the following additional changes: -

    -
  • create a $CATALINA_BASE/bin directory
  • -
  • create a $CATALINA_BASE/lib directory
  • -
  • if running with a security manager, adjust the codebase for JULI in - $CATALINA_BASE/conf/catalina.policy
  • -
-

+

Additional notes

+
    +
  • This exposes log4j libraries to the web applications through the + Common classloader. See class loading + documentation for details.

    +

    Because of that, the web applications and libraries using + Apache Commons Logging + library are likely to automatically choose log4j as the underlying + logging implementation.

  • + +
  • The java.util.logging API is still available, for + those web applications that use it directly. The + ${catalina.base}/conf/logging.properties file is still + referenced by Tomcat startup scripts.

    +

    Removal of ${catalina.base}/conf/logging.properties + file, mentioned as one of the steps, just causes + java.util.logging to fallback to the default configuration + as configured in JRE, which is to use a ConsoleHandler and do not + create any files.

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