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
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):
-
Thanks, could you show a config example using the retainedFileCountLimit setting to change the default number of days? Commented 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.