本文介绍了如何配置Tomcat JULI日志记录以滚动日志文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个使用java.util.logging的webapps。 Tomcat 5.5配置为使用Juli记录器,以便每个webapp都有自己的日志文件。问题是Juli没有最大文件大小和文件数的属性。使用Juli文件将无限增长,并且只在一天结束时滚动。此外,还保留了无限数量的日志文件。

I have a several webapps which use java.util.logging. Tomcat 5.5 is configured to use the Juli logger so that each webapp has its own log file. The problem is that Juli does not have properties for maximum file size and file count. Using Juli the files will grow unbounded and only roll at the end of the day. Also, an unlimited number of log files are retained.

您可以在此页面上看到FileHandler属性 -

没有限制或计数属性(以下行无效)

org.apache.juli.FileHandler.limit = 102400

org.apache.juli.FileHandler.count = 5

You can see the FileHandler properties on this page - Apache Tomcat 5.5 Documentation
There is no limit or count property (the following lines do nothing)
org.apache.juli.FileHandler.limit=102400
org.apache.juli.FileHandler.count=5

在不更改webapps的情况下,有没有办法为每个应用程序获取日志文件大小的某种类型的边界的唯一日志文件?

Without changing the webapps is there a way to get unique log files for each application with some type of bounds on the log file sizes?

更新:
我发现的解决方案根本就没有使用Juli记录器!
java.util.logging.FileHandler.limit = 102400

java.util.logging.FileHandler.count = 5

谢谢,

Greg

推荐答案

编辑:刚刚意识到您希望每个webapp日志记录可能无法通过此设置进行...

Just realized you wanted per webapp logging which might not be possible with this setup...

我的建议是,假设你使用的是Tomcat 6.0,那就是为完整的commons-logging编译额外的组件,并使用Log4j来配置滚动日志。

My suggestion, assuming your are using Tomcat 6.0, is to compile the extra component for full commons-logging and use Log4j to configure rolling logs.

此处的建筑说明

然后替换/ bin目录中的tomcat-juli.jar将Tomcat-juli-adapters.jar与log4j.jar和log4j.properties一起放在/ lib目录中。

Then replace the tomcat-juli.jar in the /bin directory of Tomcat and place the tomcat-juli-adapters.jar in the /lib directory along with log4j.jar and log4j.properties.

然后使用类似的东西:

<appender name="file" class="org.apache.log4j.RollingFileAppender">
  <param name="File" value="logfile.log"/>
  <param name="Threshold" value="INFO"/>
  <param name="MaxFileSize" value="10MB"/>
  <param name="MaxBackupIndex" value="3"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{ISO8601} %p %m%n"/>
  </layout>
</appender>

这篇关于如何配置Tomcat JULI日志记录以滚动日志文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 05:00