Understanding Tomcat Log Files: catalina.out, catalina.{date}.log, and localhost.{date}.log

This article explains the purpose and generation of Tomcat's default log files—catalina.out, catalina.{yyyy‑MM‑dd}.log, and localhost.{yyyy‑MM‑dd}.log—how they are configured via logging.properties and server.xml, and which types of messages appear in each file to aid troubleshooting.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
Understanding Tomcat Log Files: catalina.out, catalina.{date}.log, and localhost.{date}.log

Logs are essential for developers to locate problems, fix bugs, and verify applications, and sometimes deployments are made just to add a log line.

Good logs are important, but knowing which log file contains the needed information is also crucial, as logs may be written to different files.

By default Tomcat creates several log files: catalina.out, catalina.{yyyy-MM-dd}.log, and localhost.{yyyy-MM-dd}.log. These defaults can be reconfigured.

These files contain different content, so troubleshooting may require checking multiple logs.

catalina.out is Tomcat's standard output (stdout) and standard error (stderr). It captures anything printed with System.out and any console appender output from logging frameworks such as Logback.

catalina.{yyyy-MM-dd}.log and localhost.{yyyy-MM-dd}.log are configured via logging.properties. A typical configuration looks like:

handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
1catalina.org.apache.juli.FileHandler.level = INFO
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler

This configuration means the root logger writes to both the catalina file and the console; the console ultimately goes to catalina.out, which explains why many entries appear in both catalina.{date}.log and catalina.out.

The localhost logger captures any log whose name matches

org.apache.catalina.core.ContainerBase.[Catalina].[localhost]

. This mapping is defined in server.xml:

<Engine name="Catalina" defaultHost="localhost">
    <Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false">
    </Host>
</Engine>

In Tomcat, an Engine corresponds to the StandardEngine class, a Host to StandardHost, and a Context to StandardContext. These classes inherit from ContainerBase, and logs related to application code use the logger name derived from the container hierarchy.

During web‑app initialization, listeners, filters, and servlets are created inside StandardContext. If a listener fails, its log appears in localhost.{date}.log because the logger name includes the Engine and Host names (Catalina and localhost) and the context name (e.g., / for ROOT). Console‑based logs from the application still go to catalina.out.

Summary : catalina.out contains stdout/stderr, including Tomcat’s own output and any console‑logged messages from the application. catalina.{date}.log holds Tomcat’s internal logs, which are also duplicated in catalina.out. localhost.{date}.log records unhandled exceptions during application initialization (listeners, filters, servlets) that prevent the app from starting.

Because multiple log files can make troubleshooting harder, many teams choose to redirect all logs to catalina.out when they run a single‑host, single‑context deployment.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendJavaloggingTomcatLog Management
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.