如何设置不限制最大文件大小的log4j? [英] How to set log4j with unlimited max file size?

查看:366
本文介绍了如何设置不限制最大文件大小的log4j?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有通过Google'ing获得关于此问题的确切答案,所以我将其摆在了小组思考的策划者手中,并确保将来可以使用高质量的答案.

I didn't get a definitive answer to this question by Google'ing, so I pose it to the groupthink masterminds and to ensure that a quality answer can be Google-able in the future.

使用log4j RollingFileAppender,我可以设置文件在翻转之前可以达到的最大大小,如下所示:

Using log4j RollingFileAppender, I can set the maximum size I want the file to reach before rolling over on itself, like so:

RollingFileAppender rfa = new RollingFileAppender();
rfa.setMaximumFileSize(500000000); // Sets the max file size to 500MB

现在,如果我从不不希望该文件被翻转怎么办?如何将RollingFileAppender的最大文件大小设置为无限制?

Now, what if I don't ever want this file to be rolled over? How do I set the RollingFileAppender maximum file size to unlimited?

推荐答案

RollingFileAppender扩展FileAppender以在日志文件达到一定大小时备份它们.

RollingFileAppender extends FileAppender to backup the log files when they reach a certain size.

如果您不想将其翻转,则只需使用 FileAppender .

If you don't want to roll it over, then simply use FileAppender.

这篇关于如何设置不限制最大文件大小的log4j?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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