• 0

# Log Files

## Question

I have successfully created an alert for a log file. My question is, How do I monitor the log file regardless of drive letter? I monitor the same log file on several servers but on some of the servers the log is under Drive E: and others it is Drive D:.

Thank you

## Recommended Posts

• 0

What kind of alert and how is the datasource configured for this log file?  If it's in a script, you could just iterate through all of the possible drives it could be on testing for the existence of that directory.  That's the easiest way I could think of doing it.

##### Share on other sites
• 0

It is a log file collector. I'm currently using an absolute path in the Logfile Path section, but was wondering if I could use wildcards since the logfile could be on drive E: or drive D:.

##### Share on other sites
• 0

Are you using PowerShell for this?  If so, something like this should work

$logfileExists=0 if(test-path D:\path\to\logfile.txt) {$logfileExists=1
}
elseif(test-path E:\path\to\logfile.txt)
{
$logfileExists=1 } else {$logfileExists=0
}
$outString="logfileExists="+$logfileExists

write-host $outString Otherwise - you can run a command like this $drives = GET-WMIOBJECT win32_logicaldisk | select DeviceID

foreach($drive in$drives)
{
#do a test-path to the path on each drive
}

Hope that helps.

##### Share on other sites
• 0

I've had to do the same as Matt has suggested.  In my case it's limited to a handful of drives, so I the script doesn't have many tests to perform.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.