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 = @’
$props = $proplist -split “`n” |% {$_.trim()}

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

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

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s