How to set log4j with unlimited max file size?

百般思念 提交于 2019-12-12 11:26:21

问题


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.

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

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?


回答1:


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

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




回答2:


Just use Long.MAX_VALUE. Then you're already on a technical limit.




回答3:


Just use a FileAppender.




回答4:


talking peanuts:

make sure your filesystem does support the filesize you want to achive. technically it will never be an unlimited filesize due to filesystem restrictions.



来源:https://stackoverflow.com/questions/2141601/how-to-set-log4j-with-unlimited-max-file-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!