Global Office Directory
More Products
Share this page
Home > Community > Technical Blogs > John West Sitecore Blog > Roll Sitecore Logs Automatically
This blog post describes how you can configure the Sitecore ASP.NET CMS to automatically move old log files to a backup subdirectory when the application initializes.
Sitecore writes diagnostic messages to a log file. When possible, Sitecore writes to a log file named after the system date, such as log.20101026.txt for the 26th of October, 2010.
If Windows does not immediately release its lock on the Sitecore log file after the application restarts, Sitecore creates a new log file, such as log.20101026.105221 on the 26th of October, 2010, around 10:52:21 AM. I seem to get a new log file each time I compile my project.
I generally only care about the latest log file, but I want to keep the old log files in case I need to refer to them at some point. If I recompile repeatedly, the log directory gets cluttered.
To make it easier for me to work with Sitecore logs, I wrote a processor for the initialize pipeline to move old logs to a backup directory. You can download the code here, but note that I did not test strenuously.
To cause Sitecore to invoke the processor, add its signature at the end of the <initalize> pipeline defined in the web.config file:
<processor type="Sitecore.Sharedsource.Pipelines.Loader.RollLogs, assembly" />
Over time, this could create many subdirectories under the logs subdirectory, but subdirectories are easier to sort and remove by hand.
You might also be interested in my previous blog post, Cut Down WebDAV Logs.
Tags: Architecture, Infrastructure, API
- Sean Holmesby July 06, 2011 at 2:29 AM
- Dwight Sands April 10, 2012 at 12:22 PM
- John West April 10, 2012 at 1:21 PM
John has over ten years of experience in the CMS industry. His areas of focus include the Sitecore community, Web industry research, Sitecore technical documentation, and product management.
This website is designed to be fully functional with scripts disabled in browser. Please contact the webmaster for any suggestions