本文介绍了如何获取log4j删除旧的旋转日志文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取log4j来删除旧的旋转日志文件?我知道我可以设置自动化作业(对于UNIX为cron,对于Windows为计划任务),但是我希望它跨平台,并且希望在应用程序的日志配置中将其作为应用程序的一部分,而不是在OS外部的单独代码中特定的脚本语言.我们的应用程序不是用OS脚本语言编写的,我也不想用它们来做这部分.

How can I get log4j to delete old rotating log files? I know I can set up automated jobs (cron for UNIX and scheduled task for Windows), but I want it cross platform, and I want it in our application's log configuration as a part of our application, rather than in separate code outside in OS specific scripting languages. Our application is not written in OS scripting languages, and I don't want to do this part of it in them.

推荐答案

RollingFileAppender执行此操作.您只需将maxBackupIndex设置为备份文件的最大值.

RollingFileAppender does this. You just need to set maxBackupIndex to the highest value for the backup file.

这篇关于如何获取log4j删除旧的旋转日志文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 12:45