KeyLimeTie Log Cleaner (file pruning application) - FREE!

  • 3/16/2008
  • Author: Brian Pautsch
  • Category: Applications
  • 1590 Views
  • 3 Comments
  • Bookmark and Share

With all of the applications running on a server, it is important to keep their output pruned. Even with a basic server running a few websites, you can expect to have:
- IIS logs
- SQL Server database backups
- Application-specific logging

Over time, these files can consume a lot of disk space and potentially disable a server. Over the past 5 years, I have worked on-site with nine clients. Of these nine clients, seven of them have encountered this problem. In fact, my most recent client had this problem last week! It happens so often that when someone said the server was was running slow and throwing errors to the web browser, the first thing I said was "I bet the hard drive is full"...and it was.

Why does it happen so often? There are many reasons, but the main reason is because nobody is monitoring the disk space (or monitoring tools are not installed) and the files aren't being properly pruned or archived. To resolve this issue, I created the KeyLimeTie Log Cleaner application free for anyone to download and use. I purposely made it very simple to configure and install; there are plenty of features and options we could add.

To get it running:
1. Download Application
2. Unzip the files to a folder on your hard drive.
3. Open the "profiles.xml" file and edit it for your needs.

<?xml version="1.0" standalone="yes"?>
<Profiles>
	<Profile>
		<!-- Keep this application's logs pruned to 15 days -->
		<Description>KeyLimeTie Log Cleaner</Description>
		<FolderPath>D:\Projects\KeyLimeTie\KeyLimeTie.LogCleaner\Logs\</FolderPath>
		<Extension>txt</Extension>
		<DelOlderThanDays>15</DelOlderThanDays>
		<Recursive>false</Recursive>
	</Profile>
	<Profile>
		<!-- Example: Keep IIS Logs pruned to 15 days -->
		<!-- Setting Recursive true prunes all ftp and website logs -->
		<!-- As new websites are added, no need to update profiles -->
		<Description>All IIS Logs</Description>
		<FolderPath>C:\Windows\system32\LogFiles\</FolderPath>
		<Extension>log</Extension>
		<DelOlderThanDays>15</DelOlderThanDays>
		<Recursive>true</Recursive>
	</Profile>
	<Profile>
		<!-- Example: Keep SQL Server backups pruned to 1 week -->
		<!-- Setting Recursive true prunes all database backups -->
		<!-- As new databases are added, no need to update profiles -->
		<Description>All Database Backups</Description>
		<FolderPath>D:\Databases\Backups\</FolderPath>
		<Extension>bak</Extension>
		<DelOlderThanDays>7</DelOlderThanDays>
		<Recursive>true</Recursive>
	</Profile>
</Profiles>

Fields:
- Description: Profile description
- Folder Path: Location of files to be deleted
- Extension: Extension of files to be deleted
- DelOlderThanDays: Number of days to delete files older than today
- Recursive: Tells application to look for files in subdirectories

Schedule Application:
I installed the software on a few servers and simply created a Scheduled Task through Windows. I have it set to run every day at 4am (after the SQL Server backups are run).

Some ideas...
- Change "Extension" option to be "MatchPattern". Right now, the code searches for all files by the extension. You can put "*" in there and it'll prune all files, but it could be made to be more powerful.
- Create as Windows Service. I have created similar applications as Windows Services...and it's very easy to change this to a Windows Service. But I wanted this first version to be very simple and simple to install. I have seen people have issues with installing Windows Services.
- Create an interface to manage the profiles. It's so easy to update this really isn't necessary.

User Comments

On 11/2/2008 jay said:

This is great. But how about also for logs that are a single long text file. Would it be possible to prune those (user selectable pruning from top or bottom of the file) so that the log file is kept under a minimum filesize? (rather than by date)?


On 6/25/2008 Rob Butler said:

Great tool! It does exactly what I need and is very flexible. Thanks for making this freely available.


On 3/16/2008 John said:

Thanks!


Leave a Comment

Name: E-Mail: URL: Security Code: Type Code: Comments: