刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 1 | <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat 7 (7.0.77) - Logging in Tomcat</title><meta name="author" content="Allistair Crossley"><meta name="author" content="Yoav Shapira"><style type="text/css" media="print">
|
| 2 | .noPrint {display: none;}
|
| 3 | td#mainBody {width: 100%;}
|
| 4 | </style><style type="text/css">
|
| 5 | code {background-color:rgb(224,255,255);padding:0 0.1em;}
|
| 6 | code.attributeName, code.propertyName {background-color:transparent;}
|
| 7 |
|
| 8 |
|
| 9 | table {
|
| 10 | border-collapse: collapse;
|
| 11 | text-align: left;
|
| 12 | }
|
| 13 | table *:not(table) {
|
| 14 | /* Prevent border-collapsing for table child elements like <div> */
|
| 15 | border-collapse: separate;
|
| 16 | }
|
| 17 |
|
| 18 | th {
|
| 19 | text-align: left;
|
| 20 | }
|
| 21 |
|
| 22 |
|
| 23 | div.codeBox pre code, code.attributeName, code.propertyName, code.noHighlight, .noHighlight code {
|
| 24 | background-color: transparent;
|
| 25 | }
|
| 26 | div.codeBox {
|
| 27 | overflow: auto;
|
| 28 | margin: 1em 0;
|
| 29 | }
|
| 30 | div.codeBox pre {
|
| 31 | margin: 0;
|
| 32 | padding: 4px;
|
| 33 | border: 1px solid #999;
|
| 34 | border-radius: 5px;
|
| 35 | background-color: #eff8ff;
|
| 36 | display: table; /* To prevent <pre>s from taking the complete available width. */
|
| 37 | /*
|
| 38 | When it is officially supported, use the following CSS instead of display: table
|
| 39 | to prevent big <pre>s from exceeding the browser window:
|
| 40 | max-width: available;
|
| 41 | width: min-content;
|
| 42 | */
|
| 43 | }
|
| 44 |
|
| 45 | div.codeBox pre.wrap {
|
| 46 | white-space: pre-wrap;
|
| 47 | }
|
| 48 |
|
| 49 |
|
| 50 | table.defaultTable tr, table.detail-table tr {
|
| 51 | border: 1px solid #CCC;
|
| 52 | }
|
| 53 |
|
| 54 | table.defaultTable tr:nth-child(even), table.detail-table tr:nth-child(even) {
|
| 55 | background-color: #FAFBFF;
|
| 56 | }
|
| 57 |
|
| 58 | table.defaultTable tr:nth-child(odd), table.detail-table tr:nth-child(odd) {
|
| 59 | background-color: #EEEFFF;
|
| 60 | }
|
| 61 |
|
| 62 | table.defaultTable th, table.detail-table th {
|
| 63 | background-color: #88b;
|
| 64 | color: #fff;
|
| 65 | }
|
| 66 |
|
| 67 | table.defaultTable th, table.defaultTable td, table.detail-table th, table.detail-table td {
|
| 68 | padding: 5px 8px;
|
| 69 | }
|
| 70 |
|
| 71 |
|
| 72 | p.notice {
|
| 73 | border: 1px solid rgb(255, 0, 0);
|
| 74 | background-color: rgb(238, 238, 238);
|
| 75 | color: rgb(0, 51, 102);
|
| 76 | padding: 0.5em;
|
| 77 | margin: 1em 2em 1em 1em;
|
| 78 | }
|
| 79 | </style></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img src="./images/tomcat.gif" align="right" alt="
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 80 | The Apache Tomcat Servlet/JSP Container
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 81 | " border="0"></a></td><td><h1><font face="arial,helvetica,sanserif">Apache Tomcat 7</font></h1><font face="arial,helvetica,sanserif">Version 7.0.77, Mar 28 2017</font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="./images/asf-logo.svg" align="right" alt="Apache Logo" border="0" style="width: 266px;height: 83px;"></a></td></tr></table><table border="0" width="100%" cellspacing="4"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><tr><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap class="noPrint"><p><strong>Links</strong></p><ul><li><a href="index.html">Docs Home</a></li><li><a href="http://wiki.apache.org/tomcat/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul><p><strong>User Guide</strong></p><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="realm-howto.html">6) Realms and AAA</a></li><li><a href="security-manager-howto.html">7) Security Manager</a></li><li><a href="jndi-resources-howto.html">8) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">9) JDBC DataSources</a></li><li><a href="class-loader-howto.html">10) Classloading</a></li><li><a href="jasper-howto.html">11) JSPs</a></li><li><a href="ssl-howto.html">12) SSL/TLS</a></li><li><a href="ssi-howto.html">13) SSI</a></li><li><a href="cgi-howto.html">14) CGI</a></li><li><a href="proxy-howto.html">15) Proxy Support</a></li><li><a href="mbeans-descriptors-howto.html">16) MBeans Descriptors</a></li><li><a href="default-servlet.html">17) Default Servlet</a></li><li><a href="cluster-howto.html">18) Clustering</a></li><li><a href="balancer-howto.html">19) Load Balancer</a></li><li><a href="connectors.html">20) Connectors</a></li><li><a href="monitoring.html">21) Monitoring and Management</a></li><li><a href="logging.html">22) Logging</a></li><li><a href="apr.html">23) APR/Native</a></li><li><a href="virtual-hosting-howto.html">24) Virtual Hosting</a></li><li><a href="aio.html">25) Advanced IO</a></li><li><a href="extras.html">26) Additional Components</a></li><li><a href="maven-jars.html">27) Mavenized</a></li><li><a href="security-howto.html">28) Security Considerations</a></li><li><a href="windows-service-howto.html">29) Windows Service</a></li><li><a href="windows-auth-howto.html">30) Windows Authentication</a></li><li><a href="jdbc-pool.html">31) Tomcat's JDBC Pool</a></li><li><a href="web-socket-howto.html">32) WebSocket</a></li></ul><p><strong>Reference</strong></p><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Tomcat Javadocs</a></li><li><a href="servletapi/index.html">Servlet Javadocs</a></li><li><a href="jspapi/index.html">JSP 2.2 Javadocs</a></li><li><a href="elapi/index.html">EL 2.2 Javadocs</a></li><li><a href="websocketapi/index.html">WebSocket 1.1 Javadocs</a></li><li><a href="http://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul><p><strong>Apache Tomcat Development</strong></p><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="http://wiki.apache.org/tomcat/TomcatVersions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="funcspecs/index.html">Functional Specs.</a></li><li><a href="tribes/introduction.html">Tribes</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left" id="mainBody"><h1>Logging in Tomcat</h1><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Table of Contents"><!--()--></a><a name="Table_of_Contents"><strong>Table of Contents</strong></a></font></td></tr><tr><td><blockquote>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 82 | <ul><li><a href="#Introduction">Introduction</a><ol><li><a href="#Java_logging_API_%E2%80%94_java.util.logging">Java logging API — java.util.logging</a></li><li><a href="#Servlets_logging_API">Servlets logging API</a></li><li><a href="#Console">Console</a></li><li><a href="#Access_logging">Access logging</a></li></ol></li><li><a href="#Using_java.util.logging_(default)">Using java.util.logging (default)</a><ol><li><a href="#Documentation_references">Documentation references</a></li><li><a href="#Considerations_for_productive_usage">Considerations for productive usage</a></li></ol></li><li><a href="#Using_Log4j">Using Log4j</a></li></ul>
|
| 83 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote>
|
| 84 | <p>
|
| 85 | Logging in Apache Tomcat is implemented with the help of
|
| 86 | <a href="http://commons.apache.org/logging">Apache Commons Logging</a>
|
| 87 | library. That library is a thin wrapper above different logging
|
| 88 | frameworks. It provides Tomcat with the ability to log
|
| 89 | hierarchically across various log levels without the need to rely on a
|
| 90 | particular logging implementation.
|
| 91 | </p>
|
| 92 |
|
| 93 | <p>
|
| 94 | Since Tomcat 6.0, Tomcat uses a private package-renamed implementation of
|
| 95 | Apache Commons Logging, to allow web applications to use their own
|
| 96 | independent copies of the original Apache Commons Logging library.
|
| 97 | In the default distribution this private copy of the library
|
| 98 | is simplified and hardcoded to use the <code>java.util.logging</code> framework.
|
| 99 | </p>
|
| 100 |
|
| 101 | <p>
|
| 102 | To configure Tomcat to use alternative logging frameworks for its internal
|
| 103 | logging, one has to replace the logging library with the one that is built
|
| 104 | with the full implementation. Such library is provided as an <a href="extras.html">extras</a>
|
| 105 | component. Instructions on how to configure Tomcat to use Log4j framework
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 106 | for its internal logging may be found <a href="#Using_Log4j">below</a>.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 107 | </p>
|
| 108 |
|
| 109 | <p>
|
| 110 | A web application running on Apache Tomcat can:
|
| 111 | </p>
|
| 112 | <ul>
|
| 113 | <li>
|
| 114 | Use system logging API, <code>java.util.logging</code>.
|
| 115 | </li>
|
| 116 | <li>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 117 | Use the logging API provided by the Java Servlets specification,
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 118 | <code>javax.servlet.ServletContext.log(...)</code>
|
| 119 | </li>
|
| 120 | <li>
|
| 121 | Use any logging framework of its choice.
|
| 122 | </li>
|
| 123 | </ul>
|
| 124 |
|
| 125 | <p>
|
| 126 | The logging frameworks used by different web applications run independently
|
| 127 | of each other. See <a href="class-loader-howto.html">class loading</a>
|
| 128 | for more details.
|
| 129 | The exception to this rule is <code>java.util.logging</code>, if it used
|
| 130 | directly or indirectly by your logging library. That is because it is loaded
|
| 131 | by the system and is shared across web applications.
|
| 132 | </p>
|
| 133 |
|
| 134 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Java logging API %E2%80%94 java.util.logging"><!--()--></a><a name="Java_logging_API_%E2%80%94_java.util.logging"><strong>Java logging API — java.util.logging</strong></a></font></td></tr><tr><td><blockquote>
|
| 135 |
|
| 136 | <p>
|
| 137 | Apache Tomcat has its own implementation of several key elements of
|
| 138 | <code>java.util.logging</code> API. This implementation is called "JULI".
|
| 139 | The key component there is a custom LogManager implementation,
|
| 140 | that is aware of different web applications running on Tomcat (and
|
| 141 | their different class loaders). It supports private per-application
|
| 142 | logging configurations. It is also notified by Tomcat when a web application
|
| 143 | is unloaded from memory, so that the references to its classes can be
|
| 144 | cleared, preventing memory leaks.
|
| 145 | </p>
|
| 146 |
|
| 147 | <p>
|
| 148 | This <code>java.util.logging</code> implementation is enabled by providing
|
| 149 | certain system properties when starting Java. The Apache Tomcat startup
|
| 150 | scripts do this for you, but if you are using different tools to run
|
| 151 | Tomcat (such as jsvc, or running Tomcat from within an IDE), you should
|
| 152 | take care of them by yourself.
|
| 153 | </p>
|
| 154 |
|
| 155 | <p>
|
| 156 | More details about java.util.logging may be found in the documentation
|
| 157 | for your JDK and on its Javadoc pages for the <code>java.util.logging</code>
|
| 158 | package.
|
| 159 | </p>
|
| 160 |
|
| 161 | <p>
|
| 162 | More details about Tomcat JULI may be found below.
|
| 163 | </p>
|
| 164 |
|
| 165 | </blockquote></td></tr></table>
|
| 166 |
|
| 167 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Servlets logging API"><!--()--></a><a name="Servlets_logging_API"><strong>Servlets logging API</strong></a></font></td></tr><tr><td><blockquote>
|
| 168 |
|
| 169 | <p>
|
| 170 | The calls to <code>javax.servlet.ServletContext.log(...)</code> to write
|
| 171 | log messages are handled by internal Tomcat logging. Such messages are
|
| 172 | logged to the category named
|
| 173 | </p>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 174 | <div class="codeBox"><pre><code>org.apache.catalina.core.ContainerBase.[${engine}].[${host}].[${context}]</code></pre></div>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 175 | <p>
|
| 176 | This logging is performed according to the Tomcat logging configuration. You
|
| 177 | cannot overwrite it in a web application.
|
| 178 | </p>
|
| 179 |
|
| 180 | <p>
|
| 181 | The Servlets logging API predates the <code>java.util.logging</code> API
|
| 182 | that is now provided by Java. As such, it does not offer you much options.
|
| 183 | E.g., you cannot control the log levels. It can be noted, though, that
|
| 184 | in Apache Tomcat implementation the calls to <code>ServletContext.log(String)</code>
|
| 185 | or <code>GenericServlet.log(String)</code> are logged at the INFO level.
|
| 186 | The calls to <code>ServletContext.log(String, Throwable)</code> or
|
| 187 | <code>GenericServlet.log(String, Throwable)</code>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 188 | are logged at the SEVERE level.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 189 | </p>
|
| 190 |
|
| 191 | </blockquote></td></tr></table>
|
| 192 |
|
| 193 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Console"><strong>Console</strong></a></font></td></tr><tr><td><blockquote>
|
| 194 |
|
| 195 | <p>
|
| 196 | When running Tomcat on unixes, the console output is usually redirected
|
| 197 | to the file named <code>catalina.out</code>. The name is configurable
|
| 198 | using an environment variable. (See the startup scripts).
|
| 199 | Whatever is written to <code>System.err/out</code> will be caught into
|
| 200 | that file. That may include:
|
| 201 | </p>
|
| 202 |
|
| 203 | <ul>
|
| 204 | <li>Uncaught exceptions printed by <code>java.lang.ThreadGroup.uncaughtException(..)</code></li>
|
| 205 | <li>Thread dumps, if you requested them via a system signal</li>
|
| 206 | </ul>
|
| 207 |
|
| 208 | <p>
|
| 209 | When running as a service on Windows, the console output is also caught
|
| 210 | and redirected, but the file names are different.
|
| 211 | </p>
|
| 212 |
|
| 213 | <p>
|
| 214 | The default logging configuration in Apache Tomcat writes the same
|
| 215 | messages to the console and to a log file. This is great when using
|
| 216 | Tomcat for development, but usually is not needed in production.
|
| 217 | </p>
|
| 218 |
|
| 219 | <p>
|
| 220 | Old applications that still use <code>System.out</code> or <code>System.err</code>
|
| 221 | can be tricked by setting <code>swallowOutput</code> attribute on a
|
| 222 | <a href="config/context.html">Context</a>. If the attribute is set to
|
| 223 | <code>true</code>, the calls to <code>System.out/err</code> during request
|
| 224 | processing will be intercepted, and their output will be fed to the
|
| 225 | logging subsystem using the
|
| 226 | <code>javax.servlet.ServletContext.log(...)</code> calls.<br>
|
| 227 | <strong>Note</strong>, that the <code>swallowOutput</code> feature is
|
| 228 | actually a trick, and it has its limitations.
|
| 229 | It works only with direct calls to <code>System.out/err</code>,
|
| 230 | and only during request processing cycle. It may not work in other
|
| 231 | threads that might be created by the application. It cannot be used to
|
| 232 | intercept logging frameworks that themselves write to the system streams,
|
| 233 | as those start early and may obtain a direct reference to the streams
|
| 234 | before the redirection takes place.
|
| 235 | </p>
|
| 236 |
|
| 237 | </blockquote></td></tr></table>
|
| 238 |
|
| 239 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Access logging"><!--()--></a><a name="Access_logging"><strong>Access logging</strong></a></font></td></tr><tr><td><blockquote>
|
| 240 |
|
| 241 | <p>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 242 | Access logging is a related but different feature, which is
|
| 243 | implemented as a <code>Valve</code>. It uses self-contained
|
| 244 | logic to write its log files. The essential requirement for
|
| 245 | access logging is to handle a large continuous stream of data
|
| 246 | with low overhead, so it only uses Apache Commons Logging for
|
| 247 | its own debug messages. This implementation approach avoids
|
| 248 | additional overhead and potentially complex configuration.
|
| 249 | Please refer to the <a href="config/valve.html#Access_Logging">Valves</a>
|
| 250 | documentation for more details on its configuration, including
|
| 251 | the various report formats.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 252 | </p>
|
| 253 |
|
| 254 | </blockquote></td></tr></table>
|
| 255 |
|
| 256 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Using java.util.logging (default)"><!--()--></a><a name="Using_java.util.logging_(default)"><strong>Using java.util.logging (default)</strong></a></font></td></tr><tr><td><blockquote>
|
| 257 |
|
| 258 | <p>
|
| 259 | The default implementation of java.util.logging provided in the JDK is too
|
| 260 | limited to be useful. A limitation of JDK Logging appears to be the
|
| 261 | inability to have per-web application logging, as the configuration is
|
| 262 | per-VM. As a result, Tomcat will, in the default configuration, replace the
|
| 263 | default LogManager implementation with a container friendly implementation
|
| 264 | called JULI, which addresses these shortcomings. It supports the same
|
| 265 | configuration mechanisms as the standard JDK java.util.logging, using either
|
| 266 | a programmatic approach, or properties files. The main difference is that
|
| 267 | per-classloader properties files can be set (which enables easy redeployment
|
| 268 | friendly webapp configuration), and the properties files support slightly
|
| 269 | extended constructs which allows more freedom for defining handlers and
|
| 270 | assigning them to loggers.
|
| 271 | </p>
|
| 272 | <p>
|
| 273 | JULI is enabled by default, and supports per classloader configuration, in
|
| 274 | addition to the regular global java.util.logging configuration. This means
|
| 275 | that logging can be configured at the following layers:
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 276 | </p>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 277 | <ul>
|
| 278 | <li>Globally. That is usually done in the
|
| 279 | <code>${catalina.base}/conf/logging.properties</code> file.
|
| 280 | The file is specified by the <code>java.util.logging.config.file</code>
|
| 281 | System property which is set by the startup scripts.
|
| 282 | If it is not readable or is not configured, the default is to use the
|
| 283 | <code>${java.home}/lib/logging.properties</code> file in the JRE.
|
| 284 | </li>
|
| 285 | <li>In the web application. The file will be
|
| 286 | <code>WEB-INF/classes/logging.properties</code>
|
| 287 | </li>
|
| 288 | </ul>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 289 | <p>
|
| 290 | The default <code>logging.properties</code> in the JRE specifies a
|
| 291 | <code>ConsoleHandler</code> that routes logging to System.err.
|
| 292 | The default <code>conf/logging.properties</code> in Apache Tomcat also
|
| 293 | adds several <code>FileHandler</code>s that write to files.
|
| 294 | </p>
|
| 295 | <p>
|
| 296 | A handler's log level threshold is INFO by default and can be set using
|
| 297 | SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST or ALL.
|
| 298 | You can also target specific packages to collect logging from and specify
|
| 299 | a level.
|
| 300 | </p>
|
| 301 | <p>
|
| 302 | Here is how you would set debugging from Tomcat. You would need to ensure the
|
| 303 | ConsoleHandler's (or FileHandler's') level is also set to collect this threshold,
|
| 304 | so FINEST or ALL should be set. Please refer to <code>java.util.logging</code>
|
| 305 | documentation in the JDK for the complete details:
|
| 306 | </p>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 307 | <div class="codeBox"><pre><code>org.apache.catalina.level=FINEST</code></pre></div>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 308 | <p>
|
| 309 | The configuration used by JULI is extremely similar to the one supported by
|
| 310 | plain <code>java.util.logging</code>, but uses a few
|
| 311 | extensions to allow better flexibility in assigning loggers. The main
|
| 312 | differences are:
|
| 313 | </p>
|
| 314 | <ul>
|
| 315 | <li>A prefix may be added to handler names, so that multiple handlers of a
|
| 316 | single class may be instantiated. A prefix is a String which starts with a
|
| 317 | digit, and ends with '.'. For example, <code>22foobar.</code> is a valid
|
| 318 | prefix.</li>
|
| 319 | <li>System property replacement is performed for property values which
|
| 320 | contain ${systemPropertyName}.</li>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 321 | <li>As in Java 6, loggers can define a list of handlers using the
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 322 | <code>loggerName.handlers</code> property.</li>
|
| 323 | <li>By default, loggers will not delegate to their parent if they have
|
| 324 | associated handlers. This may be changed per logger using the
|
| 325 | <code>loggerName.useParentHandlers</code> property, which accepts a
|
| 326 | boolean value.</li>
|
| 327 | <li>The root logger can define its set of handlers using the
|
| 328 | <code>.handlers</code> property.</li>
|
| 329 | </ul>
|
| 330 | <p>
|
| 331 | There are several additional implementation classes, that can be used
|
| 332 | together with the ones provided by Java. The notable one is
|
| 333 | <code>org.apache.juli.FileHandler</code>.
|
| 334 | </p>
|
| 335 | <p>
|
| 336 | <code>org.apache.juli.FileHandler</code> supports buffering of the
|
| 337 | logs. The buffering is not enabled by default. To configure it, use the
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 338 | <code>bufferSize</code> property of a handler. The value of <code>0</code>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 339 | uses system default buffering (typically an 8K buffer will be used). A
|
| 340 | value of <code><0</code> forces a writer flush upon each log write. A
|
| 341 | value <code>>0</code> uses a BufferedOutputStream with the defined
|
| 342 | value but note that the system default buffering will also be
|
| 343 | applied.
|
| 344 | </p>
|
| 345 | <p>
|
| 346 | Example logging.properties file to be placed in $CATALINA_BASE/conf:
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 347 | </p>
|
| 348 | <div class="codeBox"><pre><code>handlers = 1catalina.org.apache.juli.FileHandler, \
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 349 | 2localhost.org.apache.juli.FileHandler, \
|
| 350 | 3manager.org.apache.juli.FileHandler, \
|
| 351 | java.util.logging.ConsoleHandler
|
| 352 |
|
| 353 | .handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
|
| 354 |
|
| 355 | ############################################################
|
| 356 | # Handler specific properties.
|
| 357 | # Describes specific configuration info for Handlers.
|
| 358 | ############################################################
|
| 359 |
|
| 360 | 1catalina.org.apache.juli.FileHandler.level = FINE
|
| 361 | 1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
|
| 362 | 1catalina.org.apache.juli.FileHandler.prefix = catalina.
|
| 363 |
|
| 364 | 2localhost.org.apache.juli.FileHandler.level = FINE
|
| 365 | 2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
|
| 366 | 2localhost.org.apache.juli.FileHandler.prefix = localhost.
|
| 367 |
|
| 368 | 3manager.org.apache.juli.FileHandler.level = FINE
|
| 369 | 3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
|
| 370 | 3manager.org.apache.juli.FileHandler.prefix = manager.
|
| 371 | 3manager.org.apache.juli.FileHandler.bufferSize = 16384
|
| 372 |
|
| 373 | java.util.logging.ConsoleHandler.level = FINE
|
| 374 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
|
| 375 |
|
| 376 |
|
| 377 | ############################################################
|
| 378 | # Facility specific properties.
|
| 379 | # Provides extra control for each logger.
|
| 380 | ############################################################
|
| 381 |
|
| 382 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
|
| 383 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = \
|
| 384 | 2localhost.org.apache.juli.FileHandler
|
| 385 |
|
| 386 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
|
| 387 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = \
|
| 388 | 3manager.org.apache.juli.FileHandler
|
| 389 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 390 | # For example, set the org.apache.catalina.util.LifecycleBase logger to log
|
| 391 | # each component that extends LifecycleBase changing state:
|
| 392 | #org.apache.catalina.util.LifecycleBase.level = FINE</code></pre></div>
|
| 393 |
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 394 | <p>
|
| 395 | Example logging.properties for the servlet-examples web application to be
|
| 396 | placed in WEB-INF/classes inside the web application:
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 397 | </p>
|
| 398 | <div class="codeBox"><pre><code>handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 399 |
|
| 400 | ############################################################
|
| 401 | # Handler specific properties.
|
| 402 | # Describes specific configuration info for Handlers.
|
| 403 | ############################################################
|
| 404 |
|
| 405 | org.apache.juli.FileHandler.level = FINE
|
| 406 | org.apache.juli.FileHandler.directory = ${catalina.base}/logs
|
| 407 | org.apache.juli.FileHandler.prefix = servlet-examples.
|
| 408 |
|
| 409 | java.util.logging.ConsoleHandler.level = FINE
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 410 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter</code></pre></div>
|
| 411 |
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 412 |
|
| 413 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Documentation references"><!--()--></a><a name="Documentation_references"><strong>Documentation references</strong></a></font></td></tr><tr><td><blockquote>
|
| 414 | <p>See the following resources for additional information:</p>
|
| 415 | <ul>
|
| 416 | <li>Apache Tomcat Javadoc for the
|
| 417 | <a href="api/org/apache/juli/package-summary.html"><code>org.apache.juli</code></a>
|
| 418 | package.
|
| 419 | </li>
|
| 420 | <li>Oracle Java 6 Javadoc for the
|
| 421 | <a href="http://docs.oracle.com/javase/6/docs/api/java/util/logging/package-summary.html"><code>java.util.logging</code></a>
|
| 422 | package.
|
| 423 | </li>
|
| 424 | </ul>
|
| 425 | </blockquote></td></tr></table>
|
| 426 |
|
| 427 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Considerations for productive usage"><!--()--></a><a name="Considerations_for_productive_usage"><strong>Considerations for productive usage</strong></a></font></td></tr><tr><td><blockquote>
|
| 428 | <p>You may want to take note of the following:</p>
|
| 429 | <ul>
|
| 430 | <li><p>Consider removing <code>ConsoleHandler</code> from configuration.</p>
|
| 431 | <p>By default (thanks to the <code>.handlers</code> setting) logging goes
|
| 432 | both to a <code>FileHandler</code> and to a <code>ConsoleHandler</code>.
|
| 433 | The output of the latter one is usually captured into a file, such as
|
| 434 | <code>catalina.out</code>. Thus you end up with two copies of the same
|
| 435 | messages.</p>
|
| 436 | </li>
|
| 437 | <li><p>Consider removing <code>FileHandler</code>s for the applications
|
| 438 | that you do not use. E.g., the one for <code>host-manager</code>.</p></li>
|
| 439 | <li><p>The handlers by default use the system default encoding to write
|
| 440 | the log files. It can be configured with <code>encoding</code> property.
|
| 441 | See Javadoc for details.</p></li>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 442 | <li><p>Consider configuring an
|
| 443 | <a href="config/valve.html#Access_Logging">Access log</a>.</p></li>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 444 | </ul>
|
| 445 | </blockquote></td></tr></table>
|
| 446 |
|
| 447 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Using Log4j"><!--()--></a><a name="Using_Log4j"><strong>Using Log4j</strong></a></font></td></tr><tr><td><blockquote>
|
| 448 | <p>
|
| 449 | This section explains how to configure Tomcat to use
|
| 450 | <a href="http://logging.apache.org/log4j/">log4j</a> rather than
|
| 451 | java.util.logging for all Tomcat's internal logging.
|
| 452 | </p>
|
| 453 | <p><em>Note</em>: The steps described in this section are needed
|
| 454 | when you want to reconfigure Tomcat to use Apache log4j for its own
|
| 455 | logging. These steps are <strong>not</strong> needed if you just want
|
| 456 | to use log4j in your own web application. — In that case, just
|
| 457 | put <code>log4j.jar</code> and <code>log4j.properties</code> into
|
| 458 | <code>WEB-INF/lib</code> and <code>WEB-INF/classes</code>
|
| 459 | of your web application.
|
| 460 | </p>
|
| 461 | <p>
|
| 462 | The following steps describe configuring log4j to output Tomcat's
|
| 463 | internal logging.
|
| 464 | </p>
|
| 465 |
|
| 466 | <ol>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 467 | <li>Create a file called <code>log4j.properties</code> with the
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 468 | following content and save it into <code>$CATALINA_BASE/lib</code></li>
|
| 469 | </ol>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 470 | <div class="codeBox"><pre><code>
|
| 471 | log4j.rootLogger = INFO, CATALINA
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 472 |
|
| 473 | # Define all the appenders
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 474 | log4j.appender.CATALINA = org.apache.log4j.DailyRollingFileAppender
|
| 475 | log4j.appender.CATALINA.File = ${catalina.base}/logs/catalina
|
| 476 | log4j.appender.CATALINA.Append = true
|
| 477 | log4j.appender.CATALINA.Encoding = UTF-8
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 478 | # Roll-over the log once per day
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 479 | log4j.appender.CATALINA.DatePattern = '.'yyyy-MM-dd'.log'
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 480 | log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
|
| 481 | log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
|
| 482 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 483 | log4j.appender.LOCALHOST = org.apache.log4j.DailyRollingFileAppender
|
| 484 | log4j.appender.LOCALHOST.File = ${catalina.base}/logs/localhost
|
| 485 | log4j.appender.LOCALHOST.Append = true
|
| 486 | log4j.appender.LOCALHOST.Encoding = UTF-8
|
| 487 | log4j.appender.LOCALHOST.DatePattern = '.'yyyy-MM-dd'.log'
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 488 | log4j.appender.LOCALHOST.layout = org.apache.log4j.PatternLayout
|
| 489 | log4j.appender.LOCALHOST.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
|
| 490 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 491 | log4j.appender.MANAGER = org.apache.log4j.DailyRollingFileAppender
|
| 492 | log4j.appender.MANAGER.File = ${catalina.base}/logs/manager
|
| 493 | log4j.appender.MANAGER.Append = true
|
| 494 | log4j.appender.MANAGER.Encoding = UTF-8
|
| 495 | log4j.appender.MANAGER.DatePattern = '.'yyyy-MM-dd'.log'
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 496 | log4j.appender.MANAGER.layout = org.apache.log4j.PatternLayout
|
| 497 | log4j.appender.MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
|
| 498 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 499 | log4j.appender.HOST-MANAGER = org.apache.log4j.DailyRollingFileAppender
|
| 500 | log4j.appender.HOST-MANAGER.File = ${catalina.base}/logs/host-manager
|
| 501 | log4j.appender.HOST-MANAGER.Append = true
|
| 502 | log4j.appender.HOST-MANAGER.Encoding = UTF-8
|
| 503 | log4j.appender.HOST-MANAGER.DatePattern = '.'yyyy-MM-dd'.log'
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 504 | log4j.appender.HOST-MANAGER.layout = org.apache.log4j.PatternLayout
|
| 505 | log4j.appender.HOST-MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
|
| 506 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 507 | log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
|
| 508 | log4j.appender.CONSOLE.Encoding = UTF-8
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 509 | log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
|
| 510 | log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
|
| 511 |
|
| 512 | # Configure which loggers log to which appenders
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 513 | log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost] = INFO, LOCALHOST
|
| 514 | log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager] =\
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 515 | INFO, MANAGER
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 516 | log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager] =\
|
| 517 | INFO, HOST-MANAGER</code></pre></div>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 518 | <ol start="2">
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 519 | <li><a href="http://logging.apache.org/log4j">Download Log4J</a>
|
| 520 | (Tomcat requires v1.2.x).</li>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 521 |
|
| 522 | <li><p>Download or build <code>tomcat-juli.jar</code> and
|
| 523 | <code>tomcat-juli-adapters.jar</code> that are available as an "extras"
|
| 524 | component for Tomcat. See <a href="extras.html">Additional Components
|
| 525 | documentation</a> for details.</p>
|
| 526 | <p>This <code>tomcat-juli.jar</code> differs from the default one. It
|
| 527 | contains the full Apache Commons Logging implementation and thus is
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 528 | able to discover the presence of log4j and configure itself.</p>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 529 | </li>
|
| 530 |
|
| 531 | <li><p>If you want to configure Tomcat to use log4j globally:</p>
|
| 532 | <ul>
|
| 533 | <li>Put <code>log4j.jar</code> and
|
| 534 | <code>tomcat-juli-adapters.jar</code> from "extras" into
|
| 535 | <code>$CATALINA_HOME/lib</code>.</li>
|
| 536 | <li>Replace <code>$CATALINA_HOME/bin/tomcat-juli.jar</code> with
|
| 537 | <code>tomcat-juli.jar</code> from "extras".</li>
|
| 538 | </ul>
|
| 539 | </li>
|
| 540 |
|
| 541 | <li><p>If you are running Tomcat with separate $CATALINA_HOME and
|
| 542 | $CATALINA_BASE and want to configure to use log4j in a single
|
| 543 | $CATALINA_BASE only:</p>
|
| 544 | <ul>
|
| 545 | <li>Create <code>$CATALINA_BASE/bin</code> and
|
| 546 | <code>$CATALINA_BASE/lib</code> directories if they do not exist.
|
| 547 | </li>
|
| 548 | <li>Put <code>log4j.jar</code> and
|
| 549 | <code>tomcat-juli-adapters.jar</code> from "extras" into
|
| 550 | <code>$CATALINA_BASE/lib</code></li>
|
| 551 | <li>Put <code>tomcat-juli.jar</code> from "extras" as
|
| 552 | <code>$CATALINA_BASE/bin/tomcat-juli.jar</code></li>
|
| 553 | <li>If you are running with a
|
| 554 | <a href="security-manager-howto.html">security manager</a>, you
|
| 555 | would need to edit the
|
| 556 | <code>$CATALINA_BASE/conf/catalina.policy</code> file to adjust
|
| 557 | it to using a different copy of tomcat-juli.jar.</li>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 558 | </ul>
|
| 559 | </li>
|
| 560 |
|
| 561 | <li><p>Delete <code>$CATALINA_BASE/conf/logging.properties</code> to
|
| 562 | prevent java.util.logging generating zero length log files.</p></li>
|
| 563 |
|
| 564 | <li><p>Start Tomcat</p></li>
|
| 565 | </ol>
|
| 566 |
|
| 567 | <p>
|
| 568 | This log4j configuration mirrors the default java.util.logging setup
|
| 569 | that ships with Tomcat: both the manager and host-manager apps get an
|
| 570 | individual log file, and everything else goes to the "catalina.log" log
|
| 571 | file. Each file is rolled-over once per day.
|
| 572 | </p>
|
| 573 |
|
| 574 | <p>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 575 | You can (and should) be more picky about which packages to include
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 576 | in the logging. Tomcat defines loggers by Engine and Host names.
|
| 577 | For example, for a more detailed Catalina localhost log, add this to the
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 578 | end of the log4j.properties above. Note that there are known issues with
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 579 | using this naming convention (with square brackets) in log4j XML based
|
| 580 | configuration files, so we recommend you use a properties file as
|
| 581 | described until a future version of log4j allows this convention.
|
| 582 | </p>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 583 | <div class="codeBox"><pre><code>log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 584 | log4j.logger.org.apache.catalina.core=DEBUG
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 585 | log4j.logger.org.apache.catalina.session=DEBUG</code></pre></div>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 586 |
|
| 587 | <p>
|
| 588 | Be warned: a level of DEBUG will produce megabytes of logging and slow
|
| 589 | startup of Tomcat. This level should be used sparingly when debugging of
|
| 590 | internal Tomcat operations is required.
|
| 591 | </p>
|
| 592 |
|
| 593 | <p>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 594 | Your web applications should certainly use their own log4j configuration.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 595 | This is valid <i>with</i> the above configuration. You would place a
|
| 596 | similar log4j.properties file in your web application's WEB-INF/classes
|
| 597 | directory, and log4jx.y.z.jar into WEB-INF/lib. Then specify your package
|
| 598 | level logging. This is a basic setup of log4j which does *not* require
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 599 | Commons-Logging, and you should consult the
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 600 | <a href="http://logging.apache.org/log4j/docs/documentation.html">log4j
|
| 601 | documentation</a> for more options. This page is intended only as a
|
| 602 | bootstrapping guide.
|
| 603 | </p>
|
| 604 |
|
| 605 | <p><em>Additional notes</em></p>
|
| 606 | <ul>
|
| 607 | <li><p>This exposes log4j libraries to the web applications through the
|
| 608 | Common classloader. See <a href="class-loader-howto.html">class loading</a>
|
| 609 | documentation for details.</p>
|
| 610 | <p>Because of that, the web applications and libraries using
|
| 611 | <a href="http://commons.apache.org/logging">Apache Commons Logging</a>
|
| 612 | library are likely to automatically choose log4j as the underlying
|
| 613 | logging implementation.</p></li>
|
| 614 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 615 | <li><p>The <code>java.util.logging</code> API is still available for
|
| 616 | those web applications that use it directly. The
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 617 | <code>${catalina.base}/conf/logging.properties</code> file is still
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 618 | referenced by Tomcat startup scripts. For more information, see the
|
| 619 | subsections of the <a href="#Introduction">Introduction</a> to
|
| 620 | this page.</p>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 621 | <p> Removal of <code>${catalina.base}/conf/logging.properties</code>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 622 | file, mentioned as one of the steps above, causes
|
| 623 | <code>java.util.logging</code> to fallback to the default
|
| 624 | configuration for the JRE, which is to use a ConsoleHandler
|
| 625 | and therefore not create any standard log files. You should
|
| 626 | confirm that all your log files are being created by log4j
|
| 627 | <i>before</i> disabling the standard mechanism.</p></li>
|
| 628 |
|
| 629 | <li><p>The <strong>Access Log Valve</strong> and
|
| 630 | <strong>ExtendedAccessLogValve</strong> use their own self-contained
|
| 631 | logging implementation, so they
|
| 632 | <strong><i>cannot be configured to use log4j</i></strong>.
|
| 633 | Refer to <a href="config/valve.html#Access_Logging">Valves</a>
|
| 634 | for specific configuration details.</p></li>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 635 | </ul>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 636 | </blockquote></td></tr></table></td></tr><tr class="noPrint"><td width="20%" valign="top" nowrap class="noPrint"></td><td width="80%" valign="top" align="left"><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="comments_section" id="comments_section"><strong>Comments</strong></a></font></td></tr><tr><td><blockquote><p class="notice"><strong>Notice: </strong>This comments section collects your suggestions
|
| 637 | on improving documentation for Apache Tomcat.<br><br>
|
| 638 | If you have trouble and need help, read
|
| 639 | <a href="http://tomcat.apache.org/findhelp.html">Find Help</a> page
|
| 640 | and ask your question on the tomcat-users
|
| 641 | <a href="http://tomcat.apache.org/lists.html">mailing list</a>.
|
| 642 | Do not ask such questions here. This is not a Q&A section.<br><br>
|
| 643 | The Apache Comments System is explained <a href="./comments.html">here</a>.
|
| 644 | Comments may be removed by our moderators if they are either
|
| 645 | implemented or considered invalid/off-topic.</p><script type="text/javascript"><!--//--><![CDATA[//><!--
|
| 646 | var comments_shortname = 'tomcat';
|
| 647 | var comments_identifier = 'http://tomcat.apache.org/tomcat-7.0-doc/logging.html';
|
| 648 | (function(w, d) {
|
| 649 | if (w.location.hostname.toLowerCase() == "tomcat.apache.org") {
|
| 650 | d.write('<div id="comments_thread"><\/div>');
|
| 651 | var s = d.createElement('script');
|
| 652 | s.type = 'text/javascript';
|
| 653 | s.async = true;
|
| 654 | s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
|
| 655 | (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
|
| 656 | }
|
| 657 | else {
|
| 658 | d.write('<div id="comments_thread"><strong>Comments are disabled for this page at the moment.<\/strong><\/div>');
|
| 659 | }
|
| 660 | })(window, document);
|
| 661 | //--><!]]></script></blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
|
| 662 | Copyright © 1999-2017, Apache Software Foundation
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 663 | </em></font></div></td></tr></table></body></html> |