Manage Exchange 2016 daily performance logs
Recently, a friend sent me a screenshot of an error reported by Exchange. Recently, this mistake has been repeated over and over again, so let me take a look at it.
Through the error message in the screenshot, we can see that the folder 'DailyPerformanceLogs'' has reached the maximum set value. This error is because Exchange Diagnostic service thought there might be data loss, so he threw the error log.
At this point of analysis, we can think of two solutions:
Disable the check of Exchange Diagnostic service log so that it is no longer checked. (cure the symptoms but not the root of the problem)
Setting method: open C:\ Program Files\ Microsoft\ Exchange Server\ V15\ bin\ Microsoft.Exchange.Diagnostics.Service.exe.config using notepad
Under 'DailyPerformanceLogs', we need to put "LogDataLoss" = "False"
Assign a separate path with more space to the log
In the daily Exchange operation and maintenance, we may encounter the log to fill up the disk and cause system problems, in order to avoid this situation, we need to manage these log files. In general, some will use backup software / tools to back up the logs. In the absence of professional backup software, we can only clean up these files manually, which will be more painful.
Here's a script I wrote to put it in the task schedule, execute it regularly every day, and clean up the log from three days ago.
#-Daily Performance Logs-#
#-define parameters-#
#-get current date-#
$Now = Get-Date
#-define amount of days-#
$Days = "3"
#-define folder where files are located-#
$TargetFolder = "C:\ Program Files\ Microsoft\ Exchange Server\ V15\ Logging\ Diagnostics\ DailyPerformanceLogs"
#-define extension-#
$Extension = "* .blg"
#-define LastWriteTime parameter based on $Days-- #
$LastWrite = $Now.AddDays (- $Days)
$Files = Get-Childitem $TargetFolder-Include $Extension-Recurse | Where {$_ .LastWriteTime-le "$LastWrite"}
Remove-Item $Files
#-W3SVC1 Folder-#
#-define folder where files are located-#
$TargetFolder1 = "C:\ inetpub\ logs\ LogFiles\ W3SVC1"
#-define extension-#
$Extension1 = "* .log"
#-define LastWriteTime parameter based on $Days-- #
$LastWrite = $Now.AddDays (- $Days)
$Files1 = Get-Childitem $TargetFolder1-Include $Extension1-Recurse | Where {$_ .LastWriteTime-le "$LastWrite"}
Remove-Item $Files1
#-W3SVC2 Folder-#
#-define folder where files are located-#
$TargetFolder2 = "C:\ inetpub\ logs\ LogFiles\ W3SVC2"
#-define extension-#
$Extension2 = "* .log"
#-define LastWriteTime parameter based on $Days-- #
$LastWrite = $Now.AddDays (- $Days)
$Files2 = Get-Childitem $TargetFolder2-Include $Extension2-Recurse | Where {$_ .LastWriteTime-le "$LastWrite"}
Remove-Item $Files2