How to configure log4j to only keep log files for the last seven days?

前端 未结 14 1501
北海茫月
北海茫月 2020-12-02 14:01

I have the following logging problem with several Java applications using log4j for logging:

I want log files to be rotated daily, like

         


        
14条回答
  •  生来不讨喜
    2020-12-02 15:01

    You can perform your housekeeping in a separate script which can be cronned to run daily. Something like this:

    find /path/to/logs -type f -mtime +7 -exec rm -f {} \;
    

提交回复
热议问题