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.
相关问题
- I want to trace logs using a Macro multi parameter
- Tomcat and SSL Client certificate
- Error message 'No handlers could be found for
- convert logback.xml to log4j.properties
- Django management command doesn't show logging
相关文章
- Tomcat的User信息可以存储到数据库中吗?
- tomcat的server.xml支持从Oracle中获取数据吗?
- web项目,Resonse Header发生解析错误,请大牛帮忙看看究竟是哪里的问题?
- Apache+Tomcat+JK实现的集群,如果Apache挂了,是不是整个服务就挂了?
- linux环境部署jpress,创建数据库时提提示连接失败
- how do I log requests and responses for debugging
- Making a two way SSL authentication between apache
- Android Studio doesn't display logs by package
The magic property for the default JULI logging in Tomcat is "rotatable". Usually there are two places where logging is defined in default installations: logging.properties and the server configurations (server.xml).
For the logging.properties you should use this: 1catalina.org.apache.juli.FileHandler.rotatable = 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:
http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Access_Log_Valve
Tomcat's logging is governed by the
<Valve>
config elements, usually inserver.xml
orcontext.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 aboutcatalina.out
, but that must use a similar mechanism.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.
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.
This should be easy on Tomcat 7: see this docs
renameOnRotate attribute
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
logging.properties
file. This removes the date from the localhost logs, and the other three log types that Tomcat dates by default: