A Powershell Module to write and read simple Logfiles.
Functions
Installation
Examples
Documentation
Changelog
Name | Description |
---|---|
Write-sLog | The Write-sLog cmdLet write a new record to a logfile. If the logfile does not exist, it will be created automatically. |
Read-sLog | The Read-sLog cmdLet read records from a logfile. |
Install from Powershell Gallery
Install-Module -Name PSsimpleLogfile
Create a record in the logfile.
Write-sLog -Path C:\temp\logfile.log -Message 'Test' -LogLevel Error
Read records with loglevel Error
Read-sLog -Path C:\temp\logfile.log -OnlyError
Create a logfile with random records
Import-Module PSsimpleLogfile
for ($i=1; $i -le 10; $i++) {
Write-sLog -Path C:\Scripts\logfile.log -LogLevel ('Info','Error','Warning' | Get-Random -Count 1) -Message ('Message {0}' -f $i)
}
Read all records from file
PS > Read-sLog -Path C:\Scripts\logfile.log
DateTime LogLevel Message
-------- -------- -------
20191129T2019067499 Error Message 1
20191129T2019067539 Error Message 2
20191129T2019067595 Warning Message 3
20191129T2019067665 Warning Message 4
20191129T2019067705 Error Message 5
20191129T2019067745 Warning Message 6
20191129T2019067775 Info Message 7
20191129T2019067815 Error Message 8
20191129T2019067855 Error Message 9
20191129T2019067905 Info Message 10
Read all records with loglevel error and warning
PS > Read-sLog -Path C:\Scripts\logfile.log -LogLevel error,warning
DateTime LogLevel Message
-------- -------- -------
20191129T2019067499 Error Message 1
20191129T2019067539 Error Message 2
20191129T2019067595 Warning Message 3
20191129T2019067665 Warning Message 4
20191129T2019067705 Error Message 5
20191129T2019067745 Warning Message 6
20191129T2019067815 Error Message 8
20191129T2019067855 Error Message 9
Read all records with loglevel info
PS > Read-sLog -Path C:\Scripts\logfile.log -OnlyInfo
DateTime LogLevel Message
-------- -------- -------
20191129T2019067775 Info Message 7
20191129T2019067905 Info Message 10
- code improvements
- Updated
Read-sLog
comment based help - Updated
Write-sLog
comment based help
- Fixed bug in
Write-sLog
that no file is created when using a PsDrive (Issue #3)
- Removed help messages for some parameters in
Read-sLog
- Updated
docs/Read-sLog.md
anddocs/Write-sLog.md
- Updated
README.md
- Updated
Read-sLog
comment based help - Removed trailing withspaces in
Read-sLog
- Updated
Write-sLog
comment based help - Removed trailing withspaces in
Write-sLog
- Initial Version
Made with ❤️ and ☕