CleanUpAgent and Log Files

Normally I have a checklist of different configurations, settings etc. I change, whenever I setup a new Sitecore solution. One of the items on the list is how long Sitecore saves the system log files. It is frustrating to investigate an error, if the system log file has been deleted.

Sitecore has an agent that handles the cleanup strategy, and by default, Sitecore deletes system log files when they are older than 7 days. It is easy to change and handled in the web.config. The cleanup strategy of the log files is managed by the Sitecore.Tasks.CleanupAgent placed at <sitecore><scheduling><agent> setting in the web.config file.


        
        
          
          
          
          
          
        
      

If you want Sitecore to store the system log files for E.g. the last 30 days, you should change the [minAge] from “7.00:00:00” attribute to “30.00:00:00”. Taking into account, the [maxCount] attribute by default is valued “20”, Sitecore will only store 20 of the system log files. Therefore, you should either change the [maxCount] to at least “30”, delete the attribute or add [rolling=”true”] to ignore the [maxCount] and [minCount] attribute.

It would look like these: