限制 Apache Tomcat 7.0 中的日志大小
我安装了 Apache Tomcat 7.0(Windows 机器)。我不擅长管理它。我们的 /logs 文件夹不断增长。 如何限制此目录/日志的文件大小?
我已经将 log4j.properties 文件添加到 /lib(步骤 1 和 2),如 Tomcat 6.0 日志页面 但这似乎无效。
我正在寻找一个配置解决方案,而不是一个疯狂的脚本或定期删除日志文件的计划任务。
I have an Apache Tomcat 7.0 install (Windows machine). I'm not fluent in managing it. Our /logs folder keeps growing. How can I limit the file size of this directory / of the logs?
I already added a log4j.properties file to /lib (steps 1 and 2) as mentioned on the Tomcat 6.0 Logging page but this seems to be ineffective.
I'm looking for a configuration solution to this, not a crazy script or scheduled task that will delete log files periodically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Log4j 并不容易设置,因为它需要 Tomcat 源。 JULI 没有配置来控制日志文件大小。由于日志文件已经在轮换(默认情况下),因此只需定期运行 shell 脚本或批处理文件即可删除所有日志文件。
Log4j is not easy to set up because it requires the Tomcat source. JULI doesn't have configuration to control log file size. Since the log files are already rotating (by default), just run a shell script or batch file periodically to delete all the log files.
您不需要任何源即可使用 Log4J。您只需直接从 Apache 下载所有 jar 文件,将它们相应地放入您的 lib 和 bin 文件夹中,然后就可以开始了。最困难的部分是创建 log4j.properties 文件,但是有很多模板可供您复制和粘贴。
You don't need any source to use Log4J. You just download all the jar files directly from Apache, put them in your lib and bin folders accordingly and you're ready to go. The most difficult part is creating a log4j.properties file, but there are plenty of templates out there you can just copy&paste.
我推荐 cronolog。这并不完全是您想要的(按大小轮换),但我发现按时间排序的日志更容易处理和搜索。
例如,您可以将 Tomcat/Apache 配置为每天轮换日志并删除/压缩一周之前的日志。或者按小时轮换并删除/归档那些较旧的几天等。
I recommend cronolog. It is not entirely what you want (to rotate by size), but I find logs sorted by time to be much more easy to process and search.
For example you can configure your Tomcat/Apache to rotate logs each day and delete/zip those older than week. Or rotate by hour and delete/archive those older that few days, etc.