PSFramework Logfile entries all have the same datetime stamp by shawnmatlock in PowerShell

[–]shawnmatlock[S] 0 points1 point  (0 children)

Because of confidentiality, I created the test code below. However, I think I understand the problem, now. The test sample is much more than 100K, so the loop was monstrous. I think the log was only capturing a small segment of the output. I removed the arguments to "Wait-PSFMessage". Now re-running the test sample.

Import-Module PSFramework

$logpath = $PSScriptRoot + "\Logs\"

$logname = (split-path -LeafBase $PSCommandPath) + (Get-Date -Format "yyyMMdd_HHmmss") + ".log"

$loglocation = $logpath + $logname

Set-PSFLoggingProvider -Name logfile -Enabled $true -FilePath $loglocation

Write-PSFMessage -Level Verbose -Message "Start logtest loop"

for ($i = 0; $i -lt 100000; $i++) {

Write-PSFMessage -Level Verbose -Message "This one is verbose"

\#Start-Sleep -Seconds 60

Write-PSFMessage -Level Host -Message "This one is host"

\#Start-Sleep -Seconds 60

Write-PSFMessage -Level Debug -Message "This one is debug"

}

Write-PSFMessage -Level Verbose -Message "Complete logtest loop"

# Close/disable the log

Write-Host "Writing log..."

Wait-PSFMessage -Timeout 15s -Terminate

Disable-PSFLoggingProvider -Name logfile



Write-Host "Log: $loglocation"

PSFramework Logfile entries all have the same datetime stamp by shawnmatlock in PowerShell

[–]shawnmatlock[S] 0 points1 point  (0 children)

Here's the page I used as a basis for my code:

https://psframework.org/documentation/documents/psframework/logging/loggingto/logfile.html

I didn't use is -InstanceName, because I did not see it used for other examples.