How to Solve Sitecore Azure Log Clean-Up Agent Issue?
Published: 20 April 2023

Logging is a crucial aspect of maintaining a Sitecore system, as it helps identify issues and resolve them.
Sitecore uses log4net settings to manage the logs in the CMS and frontend website, and tracks DEBUG, ERROR, INFO, and WARN level errors.
The logs are typically stored in the App_Data\logs folder, and Sitecore provides a clean-up agent to remove old logs and free up disk space.
Please refer the below given clean-up agent settings which Sitecore has provided by default:

However, when hosting Sitecore in Azure, the log files may have a different naming convention, such as azure..txt. Additionally, if Sitecore creates a file with a number appended to the end, such as log txt.number, the default clean-up agent may not remove it because the pattern does not include the number suffix.
Solution:
Please refer below solution to clean up the azure logs in your instance:
For removing all logs file, you have to update the above configuration with below settings:

To solve this issue, a patch file can be created to update the clean-up agent settings.
For Azure, a new agent has been added specifically to clean up the Sitecore Azure log files, as the default settings do not clear them.
The maxAge value can also be updated to retain only the last 7 days of logs, to avoid disk space and backup issues in the Azure environment.
Conclusion

Maulik Dudharejia - Co-Founder & CMO - ADDACT
Sitecore MVP 2021-23 || Digital Transformation Strategist || Marketer
Maulik Dudharejia is a visionary author, co-founder, Chief Marketing Officer, and a digital transformation expert with over 12+ years' of experience. He leverages industry certifications to translate complex tech concepts into engaging writing. His areas of expertise include Sitecore, IoT, and IT Service Management. Maulik offers valuable insights and strategies to help readers navigate the evolving tech landscape.