I understand tail.exe, and that's a good idea, but that's not exactly what we need.
I know that IIS log analyzers like deepmetrix and awstats dont seem to have a problem polling the IIS/FTP logs for a website regularly, and I still don't see why this isn't possible.
Here's the code we're using to open the logfile:
function openfile([string] $filename, [int] $offset, [ref] $filestreamInput, [ref] $streamReader)
{
if ([system.io.file]::exists($filename))
{
#write-host "openfile: $file exists"
}
else
{
write-host "openfile: $file does not exist"
return -1
}
$filestreamInput.Value = new-object system.io.filestream($filename,
[system.io.filemode]::open,
[system.io.fileaccess]::read,
[system.io.fileshare]::read)
$streamReader.Value = new-object system.io.streamreader($filestreamInput.value)
if ($offset -gt 0)
{
write-host "openfile: setting start position to " + $offset
$filestreamInput.Value.Position = $offset
}
write-host ("openfile: $file length " + $filestreamInput.Value.Length)
return $filestreamInput.Value.Length
}
function closefile ($filestreamInput, $streamReader)
{
if ($streamReader)
{
$streamReader.Close()
}
if ($filestreamInput)
{
$filestreamInput.Close()
}
}
I appreciate your help and I am sure there is a way to make this work if other programs can!
function openfile([string] $filename, [int] $offset, [ref] $filestreamInput, [ref] $streamReader)
{
if ([system.io.file]::exists($filename))
{
#write-host "openfile: $file exists"
}
else
{
write-host "openfile: $file does not exist"
return -1
}
$filestreamInput.Value = new-object system.io.filestream($filename,
[system.io.filemode]::open,
[system.io.fileaccess]::read,
[system.io.fileshare]::read)
$streamReader.Value = new-object system.io.streamreader($filestreamInput.value)
if ($offset -gt 0)
{
write-host "openfile: setting start position to " + $offset
$filestreamInput.Value.Position = $offset
}
write-host ("openfile: $file length " + $filestreamInput.Value.Length)
return $filestreamInput.Value.Length
}
function closefile ($filestreamInput, $streamReader)
{
if ($streamReader)
{
$streamReader.Close()
}
if ($filestreamInput)
{
$filestreamInput.Close()
}
}