可以将java.util.logging配置为使用压缩日志文件吗? [英] Can java.util.logging be configured to use compressed log files?

查看:191
本文介绍了可以将java.util.logging配置为使用压缩日志文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用新的日志文件滚动"到java.util.logging时,是否可以将其配置为压缩日志文件?例如,从我的日志配置文件中提取的内容如下所示:

Is it possible to configure java.util.logging to compress log files when it "rolls" onto using a new log file? For example, an extract from my log configuration file looks like this:

java.util.logging.FileHandler.level     = ALL
java.util.logging.FileHandler.pattern   = /blah.log
java.util.logging.FileHandler.limit     = 10000000
java.util.logging.FileHandler.count     = 5

理想情况下,我希望将当前日志消息写入blah.log.0,同时保留blah.log.1.gz,blah.log.2.gz等.

Ideally I would like current log messages to be written to blah.log.0 whilst retaining blah.log.1.gz, blah.log.2.gz, etc.

还请注意,我不想使用其他日志记录框架.

Also please note that I do not wish to use a different logging framework.

推荐答案

是的,但是您必须编写自己的文件处理程序.只需复制 FileHandler 进入您的项目(您不能以任何有用的方式扩展该类)并修改MeteredStreamopen()方法.

Yes but you must write your own file handler. Just copy the source code for FileHandler into your project (you can't extend the class in any useful way) and modify the open() method of MeteredStream.

之后,只需使用常规配置即可使用新的处理程序.

After that, just use the normal configuration to use your new handler.

这篇关于可以将java.util.logging配置为使用压缩日志文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆