Moving Exchange 2013 logs from default folders with Powershell
As you know, there are many types of Exchange 2013 logs, and a lot of disk space is used - and - space on system disk. Theoretically, you can change paths of all logs in Powershell. But because of number of logs types in Exchange, managing all these folders (and file sizes, directory sizes, max age of files) becomes a true nightmare.
Thus I created for me and you a little memo in Powershell scripts, so I can run them after installing of next new server.
Logs for different roles in Exchange 2013
As you know, there are only two roles in Exchange 2013: Client Access Server (CAS) and MailBox Server. Almost all useful logs are generated by Transport Services.
CAS have only one transport service - FrontEnd Transport Service.
MailBox have two:
- TransportService
- MailboxTransportService
Also MailBox have Assistants, which also involved in logs-generating.
So I've created two scripts. First - for CAS and second for MailBox Server.
Moving logs on Client Access Server in Exchange 2013
$exchangeservername = ""; # Server Name $MaxAge = 30; # Maximum number of log files we are going to keep in days $MaxDirectorySize = "3 GB"; # Maximum directory size for log-folders $MaxFileSize = "500 MB"; # Maximum size of single log file $FrontendTransportServiceBaseLogPath = "d:\exchange_logs\FrontendTransportService\"; # Base path to logs Set-FrontendTransportService -Identity $exchangeservername ` -AgentLogPath $($FrontendTransportServiceBaseLogPath + "AgentLog") ` -AgentLogMaxAge $MaxAge ` -AgentLogMaxDirectorySize $MaxDirectorySize ` -AgentLogMaxFileSize $MaxFileSize ` -ConnectivityLogPath $($FrontendTransportServiceBaseLogPath + "Connectivity") ` -ConnectivityLogMaxAge $MaxAge ` -ConnectivityLogMaxDirectorySize $MaxDirectorySize ` -ConnectivityLogMaxFileSize $MaxFileSize ` -ReceiveProtocolLogPath $($FrontendTransportServiceBaseLogPath + "ProtocolLog-SmtpReceive") ` -ReceiveProtocolLogMaxAge $MaxAge ` -ReceiveProtocolLogMaxDirectorySize $MaxDirectorySize ` -ReceiveProtocolLogMaxFileSize $MaxFileSize ` -SendProtocolLogPath $($FrontendTransportServiceBaseLogPath + "ProtocolLog-SmtpSend") ` -SendProtocolLogMaxAge $MaxAge ` -SendProtocolLogMaxDirectorySize $MaxDirectorySize ` -SendProtocolLogMaxFileSize $MaxFileSize
Please note a comments in scipt.
After running the script, it is better to reboot the server.
Fortunatelly, there is no need to create all these directories manually - Exchange will create them automatically.
Moving logs on MailBox Server in Exchange 2013
$exchangeservername = ""; # Server Name $MaxAge = 30; # Maximum number of log files we are going to keep in days $MaxDirectorySize = "3 GB"; # Maximum directory size for log-folders $MaxFileSize = "500 MB"; # Maximum size of single log file $TransportServiceBaseLogPath = "d:\exchange_logs\TransportService\"; # Base path to logs $MailboxServerBaseLogPath = "d:\exchange_logs\MailboxServer\"; # Base path to logs $MailboxTransportServiceBaseLogPath = "d:\exchange_logs\MailboxTransportService\"; # Base path to logs Set-TransportService -Identity $exchangeservername ` -ConnectivityLogPath $($TransportServiceBaseLogPath + "Hub-Connectivity") ` -ConnectivityLogMaxAge $MaxAge ` -ConnectivityLogMaxDirectorySize $MaxDirectorySize ` -ConnectivityLogMaxFileSize $MaxFileSize ` -MessageTrackingLogPath $($TransportServiceBaseLogPath + "MessageTracking") ` -MessageTrackingLogMaxAge $MaxAge ` -MessageTrackingLogMaxDirectorySize $MaxDirectorySize ` -MessageTrackingLogMaxFileSize $MaxFileSize ` -IrmLogPath $($TransportServiceBaseLogPath + "IRMLogs") ` -IrmLogMaxAge $MaxAge ` -IrmLogMaxDirectorySize $MaxDirectorySize ` -IrmLogMaxFileSize $MaxFileSize ` -ActiveUserStatisticsLogPath $($TransportServiceBaseLogPath + "Hub-ActiveUsersStats") ` -ActiveUserStatisticsLogMaxAge $MaxAge ` -ActiveUserStatisticsLogMaxDirectorySize $MaxDirectorySize ` -ActiveUserStatisticsLogMaxFileSize $MaxFileSize ` -ServerStatisticsLogPath $($TransportServiceBaseLogPath + "Hub-ServerStats") ` -ServerStatisticsLogMaxAge $MaxAge ` -ServerStatisticsLogMaxDirectorySize $MaxDirectorySize ` -ServerStatisticsLogMaxFileSize $MaxFileSize ` -ReceiveProtocolLogPath $($TransportServiceBaseLogPath + "ProtocolLog-SmtpReceive") ` -ReceiveProtocolLogMaxAge $MaxAge ` -ReceiveProtocolLogMaxDirectorySize $MaxDirectorySize ` -ReceiveProtocolLogMaxFileSize $MaxFileSize ` -RoutingTableLogPath $($TransportServiceBaseLogPath + "Hub-Routing") ` -RoutingTableLogMaxAge $MaxAge ` -RoutingTableLogMaxDirectorySize $MaxDirectorySize ` -SendProtocolLogPath $($TransportServiceBaseLogPath + "ProtocolLog-SmtpSend") ` -SendProtocolLogMaxAge $MaxAge ` -SendProtocolLogMaxDirectorySize $MaxDirectorySize ` -SendProtocolLogMaxFileSize $MaxFileSize ` -QueueLogPath $($TransportServiceBaseLogPath + "Hub-QueueViewer") ` -QueueLogMaxAge $MaxAge ` -QueueLogMaxDirectorySize $MaxDirectorySize ` -QueueLogMaxFileSize $MaxFileSize ` -WlmLogPath $($TransportServiceBaseLogPath + "Hub-WLM") ` -WlmLogMaxAge $MaxAge ` -WlmLogMaxDirectorySize $MaxDirectorySize ` -WlmLogMaxFileSize $MaxFileSize ` -PipelineTracingPath $($TransportServiceBaseLogPath + "Hub-PipelineTracing") ` -AgentLogPath $($TransportServiceBaseLogPath + "Hub-AgentLog") ` -AgentLogMaxAge $MaxAge ` -AgentLogMaxDirectorySize $MaxDirectorySize ` -AgentLogMaxFileSize $MaxFileSize Set-MailboxServer -Identity $exchangeservername ` -CalendarRepairLogPath $($MailboxServerBaseLogPath + "Calendar Repair Assistant") ` -CalendarRepairLogFileAgeLimit $MaxAge ` -CalendarRepairLogDirectorySizeLimit "2047 MB" ` -MigrationLogFilePath $($MailboxServerBaseLogPath + "Migration Assistant") Set-MailboxTransportService -Identity $exchangeservername ` -ConnectivityLogPath $($MailboxTransportServiceBaseLogPath + "Connectivity") ` -ConnectivityLogMaxAge $MaxAge ` -ConnectivityLogMaxDirectorySize $MaxDirectorySize ` -ConnectivityLogMaxFileSize $MaxFileSize ` -MailboxDeliveryAgentLogPath $($MailboxTransportServiceBaseLogPath + "AgentLog-Delivery") ` -MailboxDeliveryAgentLogMaxAge $MaxAge ` -MailboxDeliveryAgentLogMaxDirectorySize $MaxDirectorySize ` -MailboxDeliveryAgentLogMaxFileSize $MaxFileSize ` -MailboxSubmissionAgentLogPath $($MailboxTransportServiceBaseLogPath + "AgentLog-Submission") ` -MailboxSubmissionAgentLogMaxAge $MaxAge ` -MailboxSubmissionAgentLogMaxDirectorySize $MaxDirectorySize ` -MailboxSubmissionAgentLogMaxFileSize $MaxFileSize ` -ReceiveProtocolLogPath $($MailboxTransportServiceBaseLogPath + "ProtocolLog-SmtpReceive") ` -ReceiveProtocolLogMaxAge $MaxAge ` -ReceiveProtocolLogMaxDirectorySize $MaxDirectorySize ` -ReceiveProtocolLogMaxFileSize $MaxFileSize ` -SendProtocolLogPath $($MailboxTransportServiceBaseLogPath + "ProtocolLog-SmtpSend") ` -SendProtocolLogMaxAge $MaxAge ` -SendProtocolLogMaxDirectorySize $MaxDirectorySize ` -SendProtocolLogMaxFileSize $MaxFileSize ` -PipelineTracingPath $($MailboxTransportServiceBaseLogPath + "PipelineTracing")
As in the previous case, pay attention on comments in script, and after running - reboot the server.
Delete Exchange logs from default folders
After we've changed settings of logging, old logs will be on theirs places, so we need delete them by ourselfes. I have a script for this action too.
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStats" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\AgentLog" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\Connectivity" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpReceive" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpSend" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Calendar Repair Assistant" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Managed Folder Assistant" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\Connectivity" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Delivery" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Submission" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpReceive" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpSend" -force -rec rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\PipelineTracing" -force -rec
script (en), exchange (en), exchange 2013 (en)
- Hits: 10468