Today we had a server go down because Commerce Engine filled up the disk space with log files. How can we configure it to automatically delete older log files? We're on Sitecore Commerce 8.2.1.

2 Answers 2


Sitecore Commerce uses Serilog for logging. The max log file count is controlled by the retainedFileCountLimit parameter which is set to 31 by default (Serilog.Sinks.File.dll --> FileLoggerConfigurationExtensions).

  • Files older than 31 days will automatically be deleted.

  • You can control the total size of the logs by limiting the maximum file size per log file by changing the FileSizeLimitBytes value in \wwwroot\config.json (default is 100 MB):

enter image description here

  • Thanks, could you show a config example using the retainedFileCountLimit setting to change the default number of days?
    – Ben Golden
    Nov 27, 2018 at 16:55

The older log files can not be deleted by sitecore commerce engine application. Sitecore commerce uses serilog logging mechanism which will be started on application start up and can not delete the files in the folder which it is logging the new files.

We can customize the startup.cs file to delete the old log files using additional coding but it may not be good practice to do that at application log level.

It should be deleted as part of application maintanance in my opinion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.