How to Manage Log Files Retention with PowerShell

Every application offers some sort of logging feature and different ways to configure it.  It’s a cornerstone the software life-cycle from the moment the app is developed, tested, deployed, even more on a daily production usage and support.  One characteristic of the logging process is for how much time do I need to keep my log files, in three words the retention period.

But if the application doesn’t allow to configure the retention period is better to prevent that a big quantity of log files will fill all ours disk space. In this simple oneliner we will not retain or archive file more older than 30 days.

TIP: Enabling the compression on the log folder can reduce logs to about 2% of the original size.

Once we saves the script we can schedule it in task scheduler.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.