Clear up Exchange Logs

In Services, disable Microsoft Exchange Health Manager Service, and Microsoft Exchange Diagnostics Service.   In Task Manager, Expand Microsoft -> Windows, Click on PLA, stop and disable the two tasks.  Change HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\16.0\Search\Diagnostics\Tracing Key: MaxTraceFileCount from 100 to 10

Delete files in C:\PF\M\ES\V15\Bin\Search\Ceres\Diagnostics\ETLTraces

Delete files in C:\PF\M\ES\V15\Bin\Search\Ceres\Diagnostics\Logs

Delete files in C:\PF\M\ES\V15\Logging\HTTPProxy

Delete files in C:\inetpub\logs\LogFiles AND delete contents of subfolders W3SVC1 and W3SVC2

Delete files in C:\PF\M\ES\V15\Logging\RpcHttp AND delete contents of subfolders W3SVC1 and W3SVC2

Set up a task to run this powershell script on a regular basis

************   Start ***************

Set-Executionpolicy RemoteSigned 



$ExchangeLoggingPath=”C:\Program Files\Microsoft\Exchange Server\V15\Logging\” 

$ETLLoggingPath=”C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\ETLTraces\” 

$ETLLoggingPath2=”C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\Logs” 

Function CleanLogfiles($TargetFolder) 

 if (Test-Path $TargetFolder) { 

  $Now = Get-Date 

  $LastWrite = $Now.AddDays(-$days) 

  $Files = Get-ChildItem $TargetFolder -Include *.log,*.blg, *.etl, *.txt -Recurse | Where {$_.LastWriteTime -le “$LastWrite”} 

  foreach ($File in $Files) 

   {Write-Host “Deleting file $File” -ForegroundColor “white”; Remove-Item $File -ErrorAction SilentlyContinue | out-null} 


Else { 

  Write-Host “The folder $TargetFolder doesn’t exist! Check the folder path!” -ForegroundColor “white” 






****************  End Script  *********************

Leave a Reply

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