Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I know how to set up logging to write to a remote location in the general case - just specify the output filename using the full UNC path (e.g. \\HOST-PC\directory\logoutput.etl) when creating the log job. However, a problem arises when new Virtual Machines are created from a master VM where logging has been enabled: each VM will be writing logs to the exact same file on the network. I need to find a way that each new VM will automatically write to a remote file unique to it.

I've tried using the %ComputerName% environment variable in the UNC path when setting up the log using logman.exe (e.g. \host\directory\%ComputerName%\log.etl) hoping that each VM would automatically expand this to include its unique name, but this doesn't work - you just get a folder named "%ComputerName%", without the variable being expanded. This is despite the fact that if you use e.g. %SystemRoot%, this does get expanded correctly (though of course this would create an invalid path in this instance). I'm not sure what causes some variables to be expanded and not others.

Any better ideas?

share|improve this question
Let me know if any of that needs clarification! –  Scott Jan 7 '14 at 12:23

1 Answer 1

up vote 0 down vote accepted

I don't see how it can be done natively with logman, but through both the UI and the COM interface, you can set the Subdirectory Format to include the computer name as a prefix.

Performance logs and alerts dialog showing the "Prefix subdirectory with computer name" option

See MSDN for documentation on how to set the option programmatically.

Edit: The checkbox in question appears on both the data set collector and the performance counter itself. The performance counter seems to have the option greyed out. Be sure to right click the item under "Data Collector Sets > User Defined" in the MMC tree to adjust the appropriate option.

Also, Powershell:

$taskName = "daily_perf_log"
$qualifiedName = "Service\{0}" -f $taskName

# retrieve the collection set
$dcss = new-object -com Pla.DataCollectorSetCollection
$dcss.GetDataCollectorSets($null, $qualifiedName)
$dcs = $dcss.Item(0)

# update
# 3 to enable, 1 to disable (http://msdn.microsoft.com/en-us/library/windows/desktop/aa371811(v=vs.85).aspx)
$dcs.SubdirectoryFormat = 3 <# Prepend computer name #>

# save
# 1 create new / 2 update / other options (http://msdn.microsoft.com/en-us/library/windows/desktop/aa371873(v=vs.85).aspx)
$dcs.Commit($qualifiedName, $null, 2 <# update only #>)
share|improve this answer
That would work perfectly - not sure how I didn't see that before! One more problem though, that tick-box is greyed out for me, any idea why? –  Scott Jan 13 '14 at 15:52
Thanks for adding that PowerShell code. However, trying it, it seems to perform a one-off rename of the directory, rather than what I would expect that tick-box to do. So if I rename the machine, the path of the log file keeps the previous name rather than automatically changing. I'll add that I'm using "Autosession\..." rather than "Service\..." as I found the latter returned 0 results. Perhaps we're thinking of different things? I don't see anything listed in the "Data Collector Sets > User Defined" pane in perfmon.exe. –  Scott Jan 28 '14 at 15:10
That does seem to be the case. If you are trying to capture all logs, perhaps have a sysprep action which sets the unique name. E.g.: log to C:\drop\logs on the base image, a sysprep action runs the script above to set to the computer name, and copies C:\drop\logs to the central server. –  Mitch Jan 28 '14 at 20:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.