Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 771 | blopes | 1 | <!DOCTYPE html SYSTEM "about:legacy-compat"> |
| 2 | <html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><link href="./images/docs-stylesheet.css" rel="stylesheet" type="text/css"><title>Apache Tomcat 9 (9.0.112) - Logging in Tomcat</title></head><body><div id="wrapper"><header><div id="header"><div><div><div class="logo noPrint"><a href="https://tomcat.apache.org/"><img alt="Tomcat Home" src="./images/tomcat.png"></a></div><div style="height: 1px;"></div><div class="asfLogo noPrint"><a href="https://www.apache.org/" target="_blank"><img src="./images/asf-logo.svg" alt="The Apache Software Foundation" style="width: 266px; height: 83px;"></a></div><h1>Apache Tomcat 9</h1><div class="versionInfo"> |
||
| 3 | Version 9.0.112, |
||
| 4 | <time datetime="2025-11-06">Nov 6 2025</time></div><div style="height: 1px;"></div><div style="clear: left;"></div></div></div></div></header><div id="middle"><div><div id="mainLeft" class="noprint"><div><nav><div><h2>Links</h2><ul><li><a href="index.html">Docs Home</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/FAQ">FAQ</a></li></ul></div><div><h2>User Guide</h2><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="host-manager-howto.html">6) Host Manager</a></li><li><a href="realm-howto.html">7) Realms and AAA</a></li><li><a href="security-manager-howto.html">8) Security Manager</a></li><li><a href="jndi-resources-howto.html">9) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">10) JDBC DataSources</a></li><li><a href="class-loader-howto.html">11) Classloading</a></li><li><a href="jasper-howto.html">12) JSPs</a></li><li><a href="ssl-howto.html">13) SSL/TLS</a></li><li><a href="ssi-howto.html">14) SSI</a></li><li><a href="cgi-howto.html">15) CGI</a></li><li><a href="proxy-howto.html">16) Proxy Support</a></li><li><a href="mbeans-descriptors-howto.html">17) MBeans Descriptors</a></li><li><a href="default-servlet.html">18) Default Servlet</a></li><li><a href="cluster-howto.html">19) Clustering</a></li><li><a href="balancer-howto.html">20) Load Balancer</a></li><li><a href="connectors.html">21) Connectors</a></li><li><a href="monitoring.html">22) Monitoring and Management</a></li><li><a href="logging.html">23) Logging</a></li><li><a href="apr.html">24) APR/Native</a></li><li><a href="virtual-hosting-howto.html">25) Virtual Hosting</a></li><li><a href="aio.html">26) Advanced IO</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><li><a href="rewrite.html">33) Rewrite</a></li><li><a href="cdi.html">34) CDI 2 and JAX-RS</a></li><li><a href="graal.html">35) AOT/GraalVM Support</a></li></ul></div><div><h2>Reference</h2><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 4.0 Javadocs</a></li><li><a href="jspapi/index.html">JSP 2.3 Javadocs</a></li><li><a href="elapi/index.html">EL 3.0 Javadocs</a></li><li><a href="websocketapi/index.html">WebSocket 1.1 Javadocs</a></li><li><a href="jaspicapi/index.html">JASPIC 1.1 Javadocs</a></li><li><a href="annotationapi/index.html">Common Annotations 1.3 Javadocs</a></li><li><a href="https://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul></div><div><h2>Apache Tomcat Development</h2><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/Tomcat+Versions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="tribes/introduction.html">Tribes</a></li></ul></div></nav></div></div><div id="mainRight"><div id="content"><h2>Logging in Tomcat</h2><h3 id="Table_of_Contents">Table of Contents</h3><div class="text"> |
||
| 5 | <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_production_usage">Considerations for production usage</a></li></ol></li><li><a href="#Using_Log4j">Using Log4j</a></li></ul> |
||
| 6 | </div><h3 id="Introduction">Introduction</h3><div class="text"> |
||
| 7 | <p> |
||
| 8 | The internal logging for Apache Tomcat uses JULI, a packaged renamed fork |
||
| 9 | of <a href="https://commons.apache.org/logging">Apache Commons Logging</a> |
||
| 10 | that is hard-coded to use the <code>java.util.logging</code> framework. |
||
| 11 | This ensures that Tomcat's internal logging and any web application |
||
| 12 | logging will remain independent, even if a web application uses Apache |
||
| 13 | Commons Logging. |
||
| 14 | </p> |
||
| 15 | |||
| 16 | <p> |
||
| 17 | To configure Tomcat to use an alternative logging framework for its |
||
| 18 | internal logging, follow the instructions provided by the alternative |
||
| 19 | logging framework for redirecting logging for applications that use |
||
| 20 | <code>java.util.logging</code>. Links to some of these instructions are |
||
| 21 | provided towards the end of this page. Keep in mind that the alternative |
||
| 22 | logging framework will need to be capable of working in an environment |
||
| 23 | where different loggers with the same name may exist in different class |
||
| 24 | loaders. |
||
| 25 | </p> |
||
| 26 | |||
| 27 | <p> |
||
| 28 | A web application running on Apache Tomcat can: |
||
| 29 | </p> |
||
| 30 | <ul> |
||
| 31 | <li> |
||
| 32 | Use any logging framework of its choice. |
||
| 33 | </li> |
||
| 34 | <li> |
||
| 35 | Use system logging API, <code>java.util.logging</code>. |
||
| 36 | </li> |
||
| 37 | <li> |
||
| 38 | Use the logging API provided by the Java Servlets specification, |
||
| 39 | <code>javax.servlet.ServletContext.log(...)</code> |
||
| 40 | </li> |
||
| 41 | </ul> |
||
| 42 | |||
| 43 | <p> |
||
| 44 | The logging frameworks used by different web applications are independent. |
||
| 45 | See <a href="class-loader-howto.html">class loading</a> for more details. |
||
| 46 | The exception to this rule is <code>java.util.logging</code>. If it is |
||
| 47 | used directly or indirectly by your logging library then elements of it |
||
| 48 | will be shared across web applications because it is loaded by the system |
||
| 49 | class loader. |
||
| 50 | </p> |
||
| 51 | |||
| 52 | <div class="subsection"><h4 id="Java_logging_API_—_java.util.logging">Java logging API — java.util.logging</h4><div class="text"> |
||
| 53 | |||
| 54 | <p> |
||
| 55 | Apache Tomcat has its own implementation of several key elements of |
||
| 56 | <code>java.util.logging</code> API. This implementation is called JULI. |
||
| 57 | The key component there is a custom LogManager implementation, |
||
| 58 | that is aware of different web applications running on Tomcat (and |
||
| 59 | their different class loaders). It supports private per-application |
||
| 60 | logging configurations. It is also notified by Tomcat when a web application |
||
| 61 | is unloaded from memory, so that the references to its classes can be |
||
| 62 | cleared, preventing memory leaks. |
||
| 63 | </p> |
||
| 64 | |||
| 65 | <p> |
||
| 66 | This <code>java.util.logging</code> implementation is enabled by providing |
||
| 67 | certain system properties when starting Java. The Apache Tomcat startup |
||
| 68 | scripts do this for you, but if you are using different tools to run |
||
| 69 | Tomcat (such as jsvc, or running Tomcat from within an IDE), you should |
||
| 70 | take care of them by yourself. |
||
| 71 | </p> |
||
| 72 | |||
| 73 | <p> |
||
| 74 | More details about java.util.logging may be found in the documentation |
||
| 75 | for your JDK and on its Javadoc pages for the <code>java.util.logging</code> |
||
| 76 | package. |
||
| 77 | </p> |
||
| 78 | |||
| 79 | <p> |
||
| 80 | More details about Tomcat JULI may be found below. |
||
| 81 | </p> |
||
| 82 | |||
| 83 | </div></div> |
||
| 84 | |||
| 85 | <div class="subsection"><h4 id="Servlets_logging_API">Servlets logging API</h4><div class="text"> |
||
| 86 | |||
| 87 | <p> |
||
| 88 | The calls to <code>javax.servlet.ServletContext.log(...)</code> to write |
||
| 89 | log messages are handled by internal Tomcat logging. Such messages are |
||
| 90 | logged to the category named |
||
| 91 | </p> |
||
| 92 | <div class="codeBox"><pre><code>org.apache.catalina.core.ContainerBase.[${engine}].[${host}].[${context}]</code></pre></div> |
||
| 93 | <p> |
||
| 94 | This logging is performed according to the Tomcat logging configuration. You |
||
| 95 | cannot overwrite it in a web application. |
||
| 96 | </p> |
||
| 97 | |||
| 98 | <p> |
||
| 99 | The Servlets logging API predates the <code>java.util.logging</code> API |
||
| 100 | that is now provided by Java. As such, it does not offer you much options. |
||
| 101 | E.g., you cannot control the log levels. It can be noted, though, that |
||
| 102 | in Apache Tomcat implementation the calls to <code>ServletContext.log(String)</code> |
||
| 103 | or <code>GenericServlet.log(String)</code> are logged at the INFO level. |
||
| 104 | The calls to <code>ServletContext.log(String, Throwable)</code> or |
||
| 105 | <code>GenericServlet.log(String, Throwable)</code> |
||
| 106 | are logged at the SEVERE level. |
||
| 107 | </p> |
||
| 108 | |||
| 109 | </div></div> |
||
| 110 | |||
| 111 | <div class="subsection"><h4 id="Console">Console</h4><div class="text"> |
||
| 112 | |||
| 113 | <p> |
||
| 114 | When running Tomcat on unixes, the console output is usually redirected |
||
| 115 | to the file named <code>catalina.out</code>. The name is configurable |
||
| 116 | using an environment variable. (See the startup scripts). |
||
| 117 | Whatever is written to <code>System.err/out</code> will be caught into |
||
| 118 | that file. That may include: |
||
| 119 | </p> |
||
| 120 | |||
| 121 | <ul> |
||
| 122 | <li>Uncaught exceptions printed by <code>java.lang.ThreadGroup.uncaughtException(..)</code></li> |
||
| 123 | <li>Thread dumps, if you requested them via a system signal</li> |
||
| 124 | </ul> |
||
| 125 | |||
| 126 | <p> |
||
| 127 | When running as a service on Windows, the console output is also caught |
||
| 128 | and redirected, but the file names are different. |
||
| 129 | </p> |
||
| 130 | |||
| 131 | <p> |
||
| 132 | The default logging configuration in Apache Tomcat writes the same |
||
| 133 | messages to the console and to a log file. This is great when using |
||
| 134 | Tomcat for development, but usually is not needed in production. |
||
| 135 | </p> |
||
| 136 | |||
| 137 | <p> |
||
| 138 | Old applications that still use <code>System.out</code> or <code>System.err</code> |
||
| 139 | can be tricked by setting <code>swallowOutput</code> attribute on a |
||
| 140 | <a href="config/context.html">Context</a>. If the attribute is set to |
||
| 141 | <code>true</code>, the calls to <code>System.out/err</code> during request |
||
| 142 | processing will be intercepted, and their output will be fed to the |
||
| 143 | logging subsystem using the |
||
| 144 | <code>javax.servlet.ServletContext.log(...)</code> calls.<br> |
||
| 145 | <strong>Note</strong>, that the <code>swallowOutput</code> feature is |
||
| 146 | actually a trick, and it has its limitations. |
||
| 147 | It works only with direct calls to <code>System.out/err</code>, |
||
| 148 | and only during request processing cycle. It may not work in other |
||
| 149 | threads that might be created by the application. It cannot be used to |
||
| 150 | intercept logging frameworks that themselves write to the system streams, |
||
| 151 | as those start early and may obtain a direct reference to the streams |
||
| 152 | before the redirection takes place. |
||
| 153 | </p> |
||
| 154 | |||
| 155 | </div></div> |
||
| 156 | |||
| 157 | <div class="subsection"><h4 id="Access_logging">Access logging</h4><div class="text"> |
||
| 158 | |||
| 159 | <p> |
||
| 160 | Access logging is a related but different feature, which is |
||
| 161 | implemented as a <code>Valve</code>. It uses self-contained |
||
| 162 | logic to write its log files. The essential requirement for |
||
| 163 | access logging is to handle a large continuous stream of data |
||
| 164 | with low overhead, so it only uses Apache Commons Logging for |
||
| 165 | its own debug messages. This implementation approach avoids |
||
| 166 | additional overhead and potentially complex configuration. |
||
| 167 | Please refer to the <a href="config/valve.html#Access_Logging">Valves</a> |
||
| 168 | documentation for more details on its configuration, including |
||
| 169 | the various report formats. |
||
| 170 | </p> |
||
| 171 | |||
| 172 | </div></div> |
||
| 173 | |||
| 174 | </div><h3 id="Using_java.util.logging_(default)">Using java.util.logging (default)</h3><div class="text"> |
||
| 175 | |||
| 176 | <p> |
||
| 177 | The default implementation of java.util.logging provided in the JDK is too |
||
| 178 | limited to be useful. The key limitation is the inability to have per-web |
||
| 179 | application logging, as the configuration is per-VM. As a result, Tomcat |
||
| 180 | will, in the default configuration, replace the default LogManager |
||
| 181 | implementation with a container friendly implementation called JULI, which |
||
| 182 | addresses these shortcomings. |
||
| 183 | </p> |
||
| 184 | <p> |
||
| 185 | JULI supports the same configuration mechanisms as the standard JDK |
||
| 186 | <code>java.util.logging</code>, using either a programmatic approach, or |
||
| 187 | properties files. The main difference is that per-classloader properties |
||
| 188 | files can be set (which enables easy redeployment friendly webapp |
||
| 189 | configuration), and the properties files support extended constructs which |
||
| 190 | allows more freedom for defining handlers and assigning them to loggers. |
||
| 191 | </p> |
||
| 192 | <p> |
||
| 193 | JULI is enabled by default, and supports per classloader configuration, in |
||
| 194 | addition to the regular global java.util.logging configuration. This means |
||
| 195 | that logging can be configured at the following layers: |
||
| 196 | </p> |
||
| 197 | <ul> |
||
| 198 | <li>Globally. That is usually done in the |
||
| 199 | <code>${catalina.base}/conf/logging.properties</code> file. |
||
| 200 | The file is specified by the <code>java.util.logging.config.file</code> |
||
| 201 | System property which is set by the startup scripts. |
||
| 202 | If it is not readable or is not configured, the default is to use the |
||
| 203 | <code>${java.home}/lib/logging.properties</code> file in the JRE. |
||
| 204 | </li> |
||
| 205 | <li>In the web application. The file will be |
||
| 206 | <code>WEB-INF/classes/logging.properties</code> |
||
| 207 | </li> |
||
| 208 | </ul> |
||
| 209 | <p> |
||
| 210 | The default <code>logging.properties</code> in the JRE specifies a |
||
| 211 | <code>ConsoleHandler</code> that routes logging to System.err. |
||
| 212 | The default <code>conf/logging.properties</code> in Apache Tomcat also |
||
| 213 | adds several <code>AsyncFileHandler</code>s that write to files. |
||
| 214 | </p> |
||
| 215 | <p> |
||
| 216 | A handler's log level threshold is <code>INFO</code> by default and can be set using |
||
| 217 | <code>SEVERE</code>, <code>WARNING</code>, <code>INFO</code>, <code>CONFIG</code>, |
||
| 218 | <code>FINE</code>, <code>FINER</code>, <code>FINEST</code> or <code>ALL</code>. |
||
| 219 | You can also target specific packages to collect logging from and specify |
||
| 220 | a level. |
||
| 221 | </p> |
||
| 222 | <p> |
||
| 223 | To enable debug logging for part of Tomcat's internals, you should |
||
| 224 | configure both the appropriate logger(s) and the appropriate handler(s) to |
||
| 225 | use the <code>FINEST</code> or <code>ALL</code> level. e.g.: |
||
| 226 | </p> |
||
| 227 | <div class="codeBox"><pre><code>org.apache.catalina.session.level=ALL |
||
| 228 | java.util.logging.ConsoleHandler.level=ALL</code></pre></div> |
||
| 229 | <p> |
||
| 230 | When enabling debug logging it is recommended that it is enabled for the |
||
| 231 | narrowest possible scope as debug logging can generate large amounts of |
||
| 232 | information. |
||
| 233 | </p> |
||
| 234 | <p> |
||
| 235 | The configuration used by JULI is the same as the one supported by plain |
||
| 236 | <code>java.util.logging</code>, but uses a few extensions to allow better |
||
| 237 | flexibility in configuring loggers and handlers. The main differences are: |
||
| 238 | </p> |
||
| 239 | <ul> |
||
| 240 | <li>A prefix may be added to handler names, so that multiple handlers of a |
||
| 241 | single class may be instantiated. A prefix is a String which starts with a |
||
| 242 | digit, and ends with '.'. For example, <code>22foobar.</code> is a valid |
||
| 243 | prefix.</li> |
||
| 244 | <li>System property replacement is performed for property values which |
||
| 245 | contain <code>${systemPropertyName}</code>.</li> |
||
| 246 | <li>If using a class loader that implements the |
||
| 247 | <code>org.apache.juli.WebappProperties</code> interface (Tomcat's |
||
| 248 | web application class loader does) then property replacement is also |
||
| 249 | performed for <code>${classloader.webappName}</code>, |
||
| 250 | <code>${classloader.hostName}</code> and |
||
| 251 | <code>${classloader.serviceName}</code> which are replaced with the |
||
| 252 | web application name, the host name and the service name respectively. |
||
| 253 | </li> |
||
| 254 | <li>By default, loggers will not delegate to their parent if they have |
||
| 255 | associated handlers. This may be changed per logger using the |
||
| 256 | <code>loggerName.useParentHandlers</code> property, which accepts a |
||
| 257 | boolean value.</li> |
||
| 258 | <li>The root logger can define its set of handlers using the |
||
| 259 | <code>.handlers</code> property.</li> |
||
| 260 | <li> By default the log files will be kept on the file system for |
||
| 261 | <code>90</code> days. This may be changed per handler using the |
||
| 262 | <code>handlerName.maxDays</code> property. If the specified value for the |
||
| 263 | property is <code>≤0</code> then the log files will be kept on the |
||
| 264 | file system forever, otherwise they will be kept the specified maximum |
||
| 265 | days.</li> |
||
| 266 | </ul> |
||
| 267 | <p> |
||
| 268 | There are several additional implementation classes, that can be used |
||
| 269 | together with the ones provided by Java. The notable ones are |
||
| 270 | <code>org.apache.juli.FileHandler</code> and <code>org.apache.juli.AsyncFileHandler</code>. |
||
| 271 | </p> |
||
| 272 | <p> |
||
| 273 | <code>org.apache.juli.FileHandler</code> supports buffering of the |
||
| 274 | logs. The buffering is not enabled by default. To configure it, use the |
||
| 275 | <code>bufferSize</code> property of a handler. The value of <code>0</code> |
||
| 276 | uses system default buffering (typically an 8K buffer will be used). A |
||
| 277 | value of <code><0</code> forces a writer flush upon each log write. A |
||
| 278 | value <code>>0</code> uses a BufferedOutputStream with the defined |
||
| 279 | value but note that the system default buffering will also be |
||
| 280 | applied. |
||
| 281 | </p> |
||
| 282 | <p> |
||
| 283 | <code>org.apache.juli.AsyncFileHandler</code> is a subclass of <code>FileHandler</code> |
||
| 284 | that queues the log messages and writes them asynchronously to the log files. |
||
| 285 | Its additional behaviour can be configured by setting some |
||
| 286 | <a href="config/systemprops.html#Logging">system properties</a>. |
||
| 287 | </p> |
||
| 288 | <p> |
||
| 289 | Example logging.properties file to be placed in $CATALINA_BASE/conf: |
||
| 290 | </p> |
||
| 291 | <div class="codeBox"><pre><code>handlers = 1catalina.org.apache.juli.AsyncFileHandler, \ |
||
| 292 | 2localhost.org.apache.juli.AsyncFileHandler, \ |
||
| 293 | 3manager.org.apache.juli.AsyncFileHandler, \ |
||
| 294 | java.util.logging.ConsoleHandler |
||
| 295 | |||
| 296 | .handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler |
||
| 297 | |||
| 298 | ############################################################ |
||
| 299 | # Handler specific properties. |
||
| 300 | # Describes specific configuration info for Handlers. |
||
| 301 | ############################################################ |
||
| 302 | |||
| 303 | 1catalina.org.apache.juli.AsyncFileHandler.level = ALL |
||
| 304 | 1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs |
||
| 305 | 1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina. |
||
| 306 | 1catalina.org.apache.juli.AsyncFileHandler.maxDays = 90 |
||
| 307 | 1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8 |
||
| 308 | |||
| 309 | 2localhost.org.apache.juli.AsyncFileHandler.level = ALL |
||
| 310 | 2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs |
||
| 311 | 2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost. |
||
| 312 | 2localhost.org.apache.juli.AsyncFileHandler.maxDays = 90 |
||
| 313 | 2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8 |
||
| 314 | |||
| 315 | 3manager.org.apache.juli.AsyncFileHandler.level = ALL |
||
| 316 | 3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs |
||
| 317 | 3manager.org.apache.juli.AsyncFileHandler.prefix = manager. |
||
| 318 | 3manager.org.apache.juli.AsyncFileHandler.bufferSize = 16384 |
||
| 319 | 3manager.org.apache.juli.AsyncFileHandler.maxDays = 90 |
||
| 320 | 3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8 |
||
| 321 | |||
| 322 | java.util.logging.ConsoleHandler.level = ALL |
||
| 323 | java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter |
||
| 324 | java.util.logging.ConsoleHandler.encoding = UTF-8 |
||
| 325 | |||
| 326 | ############################################################ |
||
| 327 | # Facility specific properties. |
||
| 328 | # Provides extra control for each logger. |
||
| 329 | ############################################################ |
||
| 330 | |||
| 331 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO |
||
| 332 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = \ |
||
| 333 | 2localhost.org.apache.juli.AsyncFileHandler |
||
| 334 | |||
| 335 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO |
||
| 336 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = \ |
||
| 337 | 3manager.org.apache.juli.AsyncFileHandler |
||
| 338 | |||
| 339 | # For example, set the org.apache.catalina.util.LifecycleBase logger to log |
||
| 340 | # each component that extends LifecycleBase changing state: |
||
| 341 | #org.apache.catalina.util.LifecycleBase.level = FINE</code></pre></div> |
||
| 342 | |||
| 343 | <p> |
||
| 344 | Example logging.properties for the servlet-examples web application to be |
||
| 345 | placed in WEB-INF/classes inside the web application: |
||
| 346 | </p> |
||
| 347 | <div class="codeBox"><pre><code>handlers = org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler |
||
| 348 | |||
| 349 | ############################################################ |
||
| 350 | # Handler specific properties. |
||
| 351 | # Describes specific configuration info for Handlers. |
||
| 352 | ############################################################ |
||
| 353 | |||
| 354 | org.apache.juli.AsyncFileHandler.level = ALL |
||
| 355 | org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs |
||
| 356 | org.apache.juli.AsyncFileHandler.prefix = ${classloader.webappName}. |
||
| 357 | org.apache.juli.AsyncFileHandler.encoding = UTF-8 |
||
| 358 | |||
| 359 | java.util.logging.ConsoleHandler.level = ALL |
||
| 360 | java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter |
||
| 361 | java.util.logging.ConsoleHandler.encoding = UTF-8</code></pre></div> |
||
| 362 | |||
| 363 | |||
| 364 | <div class="subsection"><h4 id="Documentation_references">Documentation references</h4><div class="text"> |
||
| 365 | <p>See the following resources for additional information:</p> |
||
| 366 | <ul> |
||
| 367 | <li>Apache Tomcat Javadoc for the |
||
| 368 | <a href="api/org/apache/juli/package-summary.html"><code>org.apache.juli</code></a> |
||
| 369 | package. |
||
| 370 | </li> |
||
| 371 | <li>Oracle Java 8 Javadoc for the |
||
| 372 | <a href="https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html"><code>java.util.logging</code></a> |
||
| 373 | package. |
||
| 374 | </li> |
||
| 375 | </ul> |
||
| 376 | </div></div> |
||
| 377 | |||
| 378 | <div class="subsection"><h4 id="Considerations_for_production_usage">Considerations for production usage</h4><div class="text"> |
||
| 379 | <p>You may want to take note of the following:</p> |
||
| 380 | <ul> |
||
| 381 | <li>Consider removing <code>ConsoleHandler</code> from configuration. By |
||
| 382 | default (thanks to the <code>.handlers</code> setting) logging goes both |
||
| 383 | to a <code>AsyncFileHandler</code> and to a <code>ConsoleHandler</code>. The |
||
| 384 | output of the latter one is usually captured into a file, such as |
||
| 385 | <code>catalina.out</code>. Thus you end up with two copies of the same |
||
| 386 | messages.</li> |
||
| 387 | <li>Consider removing <code>AsyncFileHandler</code>s for the applications |
||
| 388 | that you do not use. E.g., the one for <code>host-manager</code>.</li> |
||
| 389 | <li>Consider configuring an |
||
| 390 | <a href="config/valve.html#Access_Logging">Access log</a>.</li> |
||
| 391 | </ul> |
||
| 392 | </div></div> |
||
| 393 | |||
| 394 | </div><h3 id="Using_Log4j">Using Log4j</h3><div class="text"> |
||
| 395 | |||
| 396 | <p>The Log4j project provides <a href="https://logging.apache.org/log4j/2.x/jakarta.html#replace-tomcat">instructions for using Log4J for Tomcat's internal logging</a>.</p> |
||
| 397 | |||
| 398 | </div></div></div></div></div><footer><div id="footer"> |
||
| 399 | Copyright © 1999-2025, The Apache Software Foundation |
||
| 400 | <br> |
||
| 401 | Apache Tomcat, Tomcat, Apache, the Apache Tomcat logo and the Apache logo |
||
| 402 | are either registered trademarks or trademarks of the Apache Software |
||
| 403 | Foundation. |
||
| 404 | </div></footer></div></body></html> |