How far back do your message tracking logs REALLY go?

Exchange lets you set both a history depth, or number of days, to keep message tracking logs.  It also lets you set a limit on how much disk space to allocate to message trackinglogs.  What happens when it reaches the disk space limit?  You start losing log history. 

When you enable message tracking logging the default settings are to keep 30 days of history, and not use more than 1GB of log space, per hub transport server.  If you’ve increased the history depth, but haven’t increased the amout of disk space to allocate to the logs, or if you have a really busy HT server you may not have the log depth you think you do.

Here’s a little function to go find all your Hub Transport servers, check their message tracking log settings, and find out how much disk space the logs are using, and what the actual history depth is on each one.

function mt_status {
$hts = get-exchangeserver |
? {$_.serverrole -match “hubtransport”}

$proplist = @’
Name
MessageTrackingLogEnabled
MessageTrackingLogMaxAge
MessageTrackingLogMaxDirectorySize
MessageTrackingLogMaxFileSize
MessageTrackingLogPath
MessageTrackingLogSubjectLoggingEnabled
NewestLog
OldestLog
CurrentLogCount
CurrentLogSize
CurrentLogHistDepth
‘@
$props = $proplist -split “`n” |% {$_.trim()}

$hts |% {get-transportserver $_.name | select $props} |% {
if ($_.messagetrackinglogenabled){
$log_unc = “\\$($_.name)\$($_.messagetrackinglogpath -replace “:”,”$”)”
$logs = gci $log_unc\*.log | sort lastwritetime
$newest_log = $logs | select -last 1
$oldest_log = $logs | select -first 1
$_.newestlog = $newest_log.name
$_.oldestlog = $oldest_log.name
$_.currentlogcount = $logs.count
$_.currentlogsize = “$([int](($logs | measure length -sum).sum / 1MB)) MB”
$_.currentloghistdepth = “$([int](($newest_log.LastWriteTime – $oldest_log.creationtime).totaldays)) days”
$_
}
}
}

Advertisements

3 responses to “How far back do your message tracking logs REALLY go?

  1. First, Powershell complains about the @ symbol not starting a line, so I remove the spaces prior to the ‘@ line, but then it runs and does absolutely nothing (no output or error, just a new command line)? What gives?

  2. Awesome
    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s