| <?xml version="1.0"?> |
| <!DOCTYPE document [ |
| <!ENTITY project SYSTEM "project.xml"> |
| ]> |
| <document url="logger.html"> |
| |
| &project; |
| |
| <properties> |
| <author email="craigmcc@apache.org">Craig R. McClanahan</author> |
| <title>The Logger Component</title> |
| </properties> |
| |
| <body> |
| |
| |
| <section name="Introduction"> |
| |
| <p>Tomcat uses the |
| <a href="http://jakarta.apache.org/commons/logging/">Commons Logging</a> |
| package to implement all logging. This includes the logging defined |
| by <code>ServletContext.log</code>.</p> |
| |
| <p>If you are interested in producing access logs like a web server does |
| (for example, to run hit count analysis software), you will want to configure |
| an <a href="valve.html#Access Log Valve">Access Log Valve</a> component on |
| your <a href="engine.html#Access Logs">Engine</a>, |
| <a href="host.html#Access Logs">Host</a>, or |
| <a href="context.html#Access Logs">Context</a>.</p> |
| |
| <blockquote><em> |
| <p>The description below uses the variable name $CATALINA_HOME |
| to refer to the directory into which you have installed Tomcat 5, |
| and is the base directory against which most relative paths are |
| resolved. However, if you have configured Tomcat 5 for multiple |
| instances by setting a CATALINA_BASE directory, you should use |
| $CATALINA_BASE instead of $CATALINA_HOME for each of these |
| references.</p> |
| </em></blockquote> |
| |
| </section> |
| |
| |
| <section name="Using Log4j"> |
| <p>One of the options for logging is to use the |
| <a href="http://logging.apache.org/log4j/">Log4j</a> package to implement |
| the logging for Tomcat. The simplest way to do this is to copy the |
| <code>log4j-x.x.x.jar</code> and the <code>commons-logging.jar</code> |
| to <em>$CATALINA_HOME/common/lib</em>. The <em>log4j.xml</em> file |
| can then be placed in <em>$CATALINA_HOME/common/classes</em>. An example |
| configuration is:</p> |
| <source> |
| <?xml version="1.0" encoding="UTF-8" ?> |
| <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
| |
| <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> |
| |
| <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> |
| <layout class="org.apache.log4j.PatternLayout"> |
| <param name="ConversionPattern" |
| value="%d %-5p [%t] %c (%F:%L) - %m%n"/> |
| </layout> |
| </appender> |
| <appender name="catalina" |
| class="org.apache.log4j.DailyRollingFileAppender"> |
| <param name="File" |
| value="${catalina.home}/logs/catalina_log.txt" /> |
| <param name="DatePattern" value="'.'yyy-MM-dd" /> |
| <layout class="org.apache.log4j.PatternLayout"> |
| <param name="ConversionPattern" |
| value="%-5p %d - %m%n"/> |
| </layout> |
| </appender> |
| <appender name="localhost" |
| class="org.apache.log4j.DailyRollingFileAppender"> |
| <param name="File" |
| value="${catalina.home}/logs/localhost_log.txt" /> |
| <param name="DatePattern" value="'.'yyy-MM-dd" /> |
| <layout class="org.apache.log4j.PatternLayout"> |
| <param name="ConversionPattern" |
| value="%-5p %d - %m%n"/> |
| </layout> |
| </appender> |
| <appender name="localhost.admin" |
| class="org.apache.log4j.DailyRollingFileAppender"> |
| <param name="File" |
| value="${catalina.home}/logs/localhost_admin_log.txt" /> |
| <param name="DatePattern" value="'.'yyy-MM-dd" /> |
| <layout class="org.apache.log4j.PatternLayout"> |
| <param name="ConversionPattern" |
| value="%-5p %d - %m%n"/> |
| </layout> |
| </appender> |
| |
| <category |
| name="org.apache.catalina.core.ContainerBase.[Catalina]" |
| additivity="false"> |
| <priority value="info" /> |
| <appender-ref ref="catalina" /> |
| </category> |
| <category |
| name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost]" |
| additivity="false"> |
| <priority value="info" /> |
| <appender-ref ref="localhost" /> |
| </category> |
| <category |
| name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin]" |
| additivity="false"> |
| <priority value="info" /> |
| <appender-ref ref="localhost.admin" /> |
| </category> |
| |
| <root> |
| <priority value ="info" /> |
| <appender-ref ref="STDOUT" /> |
| </root> |
| |
| </log4j:configuration> |
| </source> |
| </section> |
| |
| |
| <section name="Using JDK1.4 logging"> |
| |
| <p><strong>TO DO</strong></p> |
| |
| </section> |
| |
| |
| |
| |
| </body> |
| |
| |
| </document> |