Email Repair

How to Clear Exchange Logs files

Maintenance of Exchange server is important for many reasons. One of the reasons is the preservation of resources as you would not need all that storage and thus it is better to minimize the resources. The larger the files, the more time it will take to open the files and require more CPU and memory to load such files. Adding to more storage means backup would take more space and more time to finish, and the performance of the server will degrade. Of course, the users will complain that the system is not fast.

If this is the only case, it would not cause any serious issue but it would be a critical problem. However, it might create other issues such as it will hinder the performance of the Exchange server, stop its services, or even damage its databases. If the hard drive or partition containing the databases would end up with no disk space, the database may get corrupt.

As an Exchange administrator, you would not want this to happen at any time. So, you need to perform correct clean up procedures.

The first thing to do is clean up the IIS logs. In most cases it is found that they tend to clog the hard drive with a big number of logs. So, you can zip and then archive them out from the server for safe keeping or for audit purposes. I am suggesting to zip them because these are large text files that can be easily compressed. Alternatively, you can delete them if these are not needed.

The logs, if installed at the default location, can be found in C:\Inetpub\logs\Logfiles. You will find two folders there - W3SVC1 and W3SVC2.

log file location

Other logs that you might archive or delete are daily performance logs and performance logs to be processed. These logs can be found in your Exchange server installation path. The default location is C:\Program Files\Microsoft\Exchange Server\v15\Logging\Diagnostics.

logging diagnostics

There is another location where the Exchange server holds a lot of logs. These logs can also be found in C:\Program Files\Microsoft\Exchange Server\v15\Logging. These are also text files and easy to zip.

Such folders include the RCPHTTP and HTTPProxy folders. To easily clear off the folder, you can either move the files to archive or delete them all at once by using the below given command line.

del *.log /s

delete logs

This will delete all the logs recursive from any folder and subfolder.

$files = Get-ChildItem -Recurse -Include *.log | Select-Object -expandproperty Name
foreach ($file in $files) {Move-Item $file $archivelocation}


This will remove any log files from the current folder to the archive location.

These will clear your Exchange server from logs. Now, the other issue is the maintenance of actual databases and their own transaction logs. To be clear, you must not assume that the transaction logs of the databases are just text files to remove at your leisure. The transaction logs of the databases hold information which is not yet committed to the database and they place an important role in the integrity and heath of the Exchange server databases.

The easiest way to clear the transaction logs is to take a backup as by time these will literally hog your server and will leave you with issues and your databases dismounted.

backup log files

These files cannot be cleared manually. The only way to clear them is with a backup run. If you are taking backup of the server daily, you would not have this issue as during a backup run, the transaction logs will be committed to database and purged. If your log files are not being purged, it means that there is an issue with your backup software or your backup software is not Exchange server compatible and not capable of taking an online backup of your Exchange databases. If your Exchange server backup is not working properly or not aware, the logs will never purge.

To solve the space problem in a crisis, you can safely purge the logs by using the method mentioned below. This will try to make the mailbox databases think that there is a backup running and a commit is initiated.

Open command prompt as admin and type the following. In the ‘Add Volume’ line, you must state the drive where you are holding your Exchange server databases.

Add Volume M:
Begin backup


This will take some time to finish, depending on the size of databases and the drive these are hosted on. Once ready, type end backup to finish off and kick off the purge process.

end backup

This is not the ideal method. It is highly suggested that you take a real backup. You can use the Windows Server Backup to back up the databases as it is application aware and fully compatible with Exchange server.

This is how you can manually purge logs and clear any logs which might be taking your Exchange server space. For businesses, it is always suggested to have a monitoring tool to keep an eye on the storage and act before a disaster strikes. The above will help you to clear out the issue. If the databases are not damaged, they will mount without any issues. But if the database is damaged or some logs are corrupt, the database will not mount and goes into Dirty Shutdown state. In such cases, a third-party application such as Stellar Repair for Exchange comes in handy. The application can open the EDB files, export them to PST or directly to a new Exchange server database and minimize the downtime while recovering all your mailboxes.


80% of people found this article helpful