Clearing the Exchange 2013 Application Log files.

Written by Saeed Mulla on. Posted in Exchange 2013, Microsoft Exchange

Microsoft Exchange Version: 2013

Tested on: Cumulative Update 3

OS: Server 2012 R2


Exchange 2013 tends to have an increased amount of application logging enabled by default. This logging is different from the Exchange database logs.

Exchange 2013 requires around 30GB of free space in the disk where Exchange 2013 is installed. Yes you read that right a whopping 30GB! Compared to Exchange 2010 which had a reasonable 1.2GB. So why the drastic increase is application logs? Well Exchange 2013 has a lot of default performance, application and other component monitoring enabled by default. Stuff which some will never use and other stuff that you *may* use on a blue moon.

If LUN allocation/capacity is an issue in your environment like it is in mine; then utilizing this precious disk space on a mailbox database / mailbox database logs is more comforting.

So you have 2 ways to fix it:

1. Increase disk space continuously as it grows. (Basically be a lazy Exchange administrator and fix the problems as they arise). OR

2. Run a script to clear out the unnecessary log files.

Before we continue you want to make sure these log files will not be required in the future for any sort of performance monitoring or IIS user audits etc. So if you have a legal department or HR investigation into users doing something they shouldn’t be doing then I would recommend sacrificing the extra disk 30GB space. If not then read on.

So there are two parts to clearing out the logs:

First check how much space your current logs are using (DISK:\Program Files\Microsoft\Exchange Server\V15\Logging) as a future reference:


Within the “Logging” directory you will see folders like these:


So now you can see the hefty folders under the Logging directory.  Out of all these the folders we are mainly interested in “Diagnostics/DailyPerformanceLogs” – here you see the the culprits:


These files basically hold information of the your servers running Exchange 2013 with parameters such as CPU, memory, disk, IOPS etc for diagnosing performance related issues.  Now in the older 2010 environment when contacting Microsoft support for diagnostics they would ask you to run performance monitoring and gather the data delaying the process to fix any issues.  In Exchange 2013 these are ready at hand with a historical copy stored in the above mentioned directory.  So you see Microsoft were being smart.

To manually clear out any logs that are not required for the running of Exchange 2013 we run the following command in a administrative powershell window (normal powershell will do).


gci ‘D:\Program Files\Microsoft\Exchange Server\V15\Logging’,’C:\inetpub\logs’ -Directory | gci -Include ‘*.log’,’*.blg’ -Recurse | ? LastWriteTime -lt (Get-Date).AddDays(-7) | Remove-Item

In the above script any files that are older than 7 days will be deleted.  You can increase or decrease this value as it suits your needs.


We will now schedule this to Windows Task Scheduler to automate this process.

Create a new task (not basic) and name it whatever you wish.  I will name mine “Clear Diagnostic Logs”. Make sure you select “Run whether user is logged on or not” option.  Also enable “Run with highest privileges”.


Now we set the time.  Mine is scheduled every morning at 7.45am.



Next is to add the powershell.exe program to the action tab and place in the script.



Now to do a test run to see if everything is OK we need to enable “Allow task to run on demand” under the Settings tab.

Run a test run and you should see “Task Completed” under the history tab.


Trackback from your site.

Leave a comment