How to remove the date pattern from tomcat logs

2019-03-09 19:11发布

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.

http://tomcat.apache.org/tomcat-6.0-doc/logging.html

8条回答
2楼-- · 2019-03-09 20:00

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.

查看更多
手持菜刀,她持情操
3楼-- · 2019-03-09 20:00

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" />
查看更多
登录 后发表回答