WriteLog
0.9.3
Apteco PS Modules - PowerShell logging script
Execute commands like
Write-Log -message "Hello World"
Write-Log -message "Hello World" -severity ([LogSeverity]::ERROR)
"Hello World" | Write-Log
The logfile getting written looks like
20210217134552 a6f3eda5-1b50-4841-861e-010174784e8c INFO Hello World
20210217134617 a6f3eda5-1b50-4841-861e-010174784e8c ER
Execute commands like
Write-Log -message "Hello World"
Write-Log -message "Hello World" -severity ([LogSeverity]::ERROR)
"Hello World" | Write-Log
The logfile getting written looks like
20210217134552 a6f3eda5-1b50-4841-861e-010174784e8c INFO Hello World
20210217134617 a6f3eda5-1b50-4841-861e-010174784e8c ER
Apteco PS Modules - PowerShell logging script
Execute commands like
Write-Log -message "Hello World"
Write-Log -message "Hello World" -severity ([LogSeverity]::ERROR)
"Hello World" | Write-Log
The logfile getting written looks like
20210217134552 a6f3eda5-1b50-4841-861e-010174784e8c INFO Hello World
20210217134617 a6f3eda5-1b50-4841-861e-010174784e8c ERROR Hello World
separated by tabs.
Make sure, the variables $logfile and $processId are present before calling this. Otherwise they will be created automatically and you are notified about the location and the current process id
The variables could be filled like
$logfile = ".\test.log"
$processId = [guid]::NewGuid()
The process id is good for parallel calls/processes so you know they belong together
Show more
Execute commands like
Write-Log -message "Hello World"
Write-Log -message "Hello World" -severity ([LogSeverity]::ERROR)
"Hello World" | Write-Log
The logfile getting written looks like
20210217134552 a6f3eda5-1b50-4841-861e-010174784e8c INFO Hello World
20210217134617 a6f3eda5-1b50-4841-861e-010174784e8c ERROR Hello World
separated by tabs.
Make sure, the variables $logfile and $processId are present before calling this. Otherwise they will be created automatically and you are notified about the location and the current process id
The variables could be filled like
$logfile = ".\test.log"
$processId = [guid]::NewGuid()
The process id is good for parallel calls/processes so you know they belong together
Minimum PowerShell version
5.1
Installation Options
Owners
Copyright
(c) 2022 Apteco GmbH. All rights reserved.
Package Details
Author(s)
- florian.von.bracht@apteco.de
Tags
PSEditions
Dependencies
This module has no dependencies.
Release Notes
0.9.3 Adding a function to clean a logfile (keep only latest n rows)
Conversion of script to module
0.9.2 Updated description and removed the return value because it can cause problems in c# calling the script
0.9.1 Initial release of logging module through psgallery
FileList
- WriteLog.nuspec
- WriteLog.psd1
- WriteLog.psm1
- Private\Invoke-CommandRetry.ps1
- Public\Get-Logfile.ps1
- Public\Resize-Logfile.ps1
- Public\Write-Log.ps1