How to remove the date pattern from tomcat logs

By default Tomcat appends the date to log files e.g., localhost.2010-12-22.log and same with the catalina log. I don't want the date in the log file and I can't seem to find how to remove it. The logging documentation doesn't say anything about the date pattern. Any ideas are greatly appreciated.


None of the other answers helped me much, though Thomas's was closest. The documentation I found was:

So I added the following to Tomcat's file. This removes the date from the localhost logs, and the other three log types that Tomcat dates by default: = false = false = false = false
   # default is true, which causes a date to be added to the filename = log = log = log = log
   # default is .log, but without date, the extra dot is not needed

de_simakov's answer was correct for the most part - but it had a one letter typo. Find a configuration similar to this in conf/server.xml

<Valve className="org.apache.catalina.valves.AccessLogValve"
      directory="logs"  prefix="http_access" suffix="log"  pattern="common" 
      rotatable="false" resolveHosts="false" />

Notice the rotatable="false" attribute.

The documentation you link to is for logging within your application, not for logging by the Tomcat server itself. As mentioned in another answer, the appropriate documentation is here. On an Ubuntu Server system, you'll want to change the settings in /etc/tomcat7/server.xml. This file may be in another location on your system.

A configuration similar to this will prevent Tomcat from putting the date in the log file name -- but it will also prevent your access log from ever being rotated by Tomcat, which is probably a bad idea unless you set up an appropriate logrotate configuration for the server.

<Valve className="org.apache.catalina.valves.AccessLogValve"
      directory="logs"  prefix="http_access" suffix="log"  pattern="common" 
      rotateable="false" resolveHosts="false" />

The magic property for the default JULI logging in Tomcat is "rotatable". Usually there are two places where logging is defined in default installations: and the server configurations (server.xml).

For the you should use this: = false

For the server configuration it would look like this:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory=" prefix="access_log" suffix=".txt" rotatable="false" pattern="%h %l %u %t "%r" %s %b" />

Please look here for further details:

The more appropriate answer to your direct question is the boolean "renameOnRotate". The assumption is that you want daily logging, but do not want the timestamp. This will name the file based on prefix/suffix, and append the timestamp to the log file after the log file has been rotated:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access" suffix=".log" renameOnRotate="true"
           pattern="%a %A %h %H %l %m %t %u %U &quot;%r&quot; %s %b " resolveHosts="false" />

Tomcat's logging is governed by the <Valve> config elements, usually in server.xml or context.xml. These allow you to control things like the data suffix.

Here's the docs for the access log value, which I assume is what you mean by localhost.2010-12-22.log. Not sure about catalina.out, but that must use a similar mechanism.

This should be easy on Tomcat 7: see this docs

renameOnRotate attribute

By default for a rotatable log the active access log file name will contain the current timestamp in fileDateFormat. During rotation the file is closed and a new file with the next timestamp in the name is created and used. When setting renameOnRotate to true, the timestamp is no longer part of the active log file name. Only during rotation the file is closed and then renamed to include the timestamp. This is similar to the behavior of most log frameworks when doing time based rotation. Default value: false

The answers quoting "renameOnRotate" are wrong. This only applies to the access log, not to the "main" logging (which is what the question wants since he's quoted 'localhost' log.

If you need both log rotation and not to have the timestamps (which is generally the case), the bad news is that it is not possible out of the box with tomcat :(

The best solution in that case is to configure it to use log4j globally, which is more flexible and will allow you to be setup in that way.

I know this is old, but for a complete example using logrotate.d, remember to replace with your tomcat version. You have to edit both, server.xml and then edit/create a logrotate config. Also, your path to the config files might be different.

logrotate config:

vi /etc/logrotate.d/tomcat<version>
    rotate 12
    create 640 tomcat adm
    rotate 12
      if invoke-rc.d tomcat<version> status > /dev/null 2>&1; then \
        invoke-rc.d tomcat<version> restart > /dev/null 2>&1; \

server.xml config: I also removed _log. from the prefix so it becomes localhost_access.log

vi /var/lib/tomcat<version>/conf/server.xml
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  prefix="localhost_access" suffix=".log" rotatable="false"
  pattern="%h %l %u %t &quot;%r&quot; %s %b" /> config:

vi /var/lib/tomcat<version>/conf/ = FINE = ${catalina.base}/logs = catalina. = log = false = FINE = ${catalina.base}/logs = localhost. = log = false = FINE = ${catalina.base}/logs = manager. = log = false = FINE = ${catalina.base}/logs = host-manager. = log = false

Need Your Help


java json google-app-engine jersey jackson

I got Jackson 2.2.3 in my buildpath but i still get this error. anyone know why?