Logging
2.3.9
Powershell Logging Module
Features
* Separate thread that dispatch messages to targets to avoid bottleneck in the main script
* Extensible with new targets
* Custom formatting
* Each target can have his own logging level
TL;DR
Set-LoggingDefaultLevel -Level 'WARNING'
Add-LoggingTarget -Name Console
Add-LoggingTarget -Name File -Configuration @{Path =
Features
* Separate thread that dispatch messages to targets to avoid bottleneck in the main script
* Extensible with new targets
* Custom formatting
* Each target can have his own logging level
TL;DR
Set-LoggingDefaultLevel -Level 'WARNING'
Add-LoggingTarget -Name Console
Add-LoggingTarget -Name File -Configuration @{Path =
Powershell Logging Module
Features
* Separate thread that dispatch messages to targets to avoid bottleneck in the main script
* Extensible with new targets
* Custom formatting
* Each target can have his own logging level
TL;DR
Set-LoggingDefaultLevel -Level 'WARNING'
Add-LoggingTarget -Name Console
Add-LoggingTarget -Name File -Configuration @{Path = 'C:\Temp\example_%{+%Y%m%d}.log'}
$Level = 'DEBUG', 'INFO', 'WARNING', 'ERROR'
foreach ($i in 1..100) {
Write-Log -Level ($Level | Get-Random) ('Message n.{0}' -f $i)
Start-Sleep -Milliseconds (Get-Random -Min 100 -Max 1000)
}
Wait-Logging # See Note
NOTE
When used in *unattended* scripts (scheduled tasks, spawned process) you need to call Wait-Logging to avoid losing messages. If you run your main script in an interactive shell that stays open at the end of the execution you could avoid using it (keep in mind that if there are messeages in the queue when you close the shell, you'll lose it)
Show more
Features
* Separate thread that dispatch messages to targets to avoid bottleneck in the main script
* Extensible with new targets
* Custom formatting
* Each target can have his own logging level
TL;DR
Set-LoggingDefaultLevel -Level 'WARNING'
Add-LoggingTarget -Name Console
Add-LoggingTarget -Name File -Configuration @{Path = 'C:\Temp\example_%{+%Y%m%d}.log'}
$Level = 'DEBUG', 'INFO', 'WARNING', 'ERROR'
foreach ($i in 1..100) {
Write-Log -Level ($Level | Get-Random) ('Message n.{0}' -f $i)
Start-Sleep -Milliseconds (Get-Random -Min 100 -Max 1000)
}
Wait-Logging # See Note
NOTE
When used in *unattended* scripts (scheduled tasks, spawned process) you need to call Wait-Logging to avoid losing messages. If you run your main script in an interactive shell that stays open at the end of the execution you could avoid using it (keep in mind that if there are messeages in the queue when you close the shell, you'll lose it)
Installation Options
Owners
Copyright
(c) 2015 Massimo Bonvicini. All rights reserved.
Package Details
Author(s)
- Massimo Bonvicini
Tags
Functions
Write-Log Add-LoggingLevel Set-LoggingDefaultLevel Get-LoggingDefaultLevel Get-LoggingDefaultFormat Set-LoggingDefaultFormat Get-LoggingTargetAvailable Get-LoggingTarget Set-LoggingCustomTargets Add-LoggingTarget Wait-Logging
Dependencies
This module has no dependencies.
FileList
- Logging.nuspec
- CONTRIBUTING.md
- LICENSE
- Logging.psd1
- Logging.psm1
- Logging.Tests.ps1
- README.md
- targets\Console.ps1
- targets\ElasticSearch.ps1
- targets\Email.ps1
- targets\File.ps1
- targets\Slack.ps1
Version History
Version | Downloads | Last updated |
---|---|---|
4.8.5 | 248,174 | 3/23/2022 |
4.8.3 | 44,838 | 10/6/2021 |
4.8.2 | 65,056 | 3/15/2021 |
4.8.1 | 5,884 | 2/18/2021 |
4.8.0 | 1,905 | 2/11/2021 |
4.7.1 | 445 | 2/11/2021 |
4.5.0 | 9,484 | 10/22/2020 |
4.4.0 | 8,092 | 6/17/2020 |
4.3.2 | 850 | 5/28/2020 |
4.3.1 | 449 | 5/28/2020 |
4.2.13 | 6,354 | 2/25/2020 |
4.2.12 | 1,613 | 11/8/2019 |
4.2.11 | 777 | 9/23/2019 |
4.2.7 | 451 | 9/19/2019 |
4.2.6 | 476 | 9/13/2019 |
4.2.3 | 541 | 8/27/2019 |
4.2.2 | 687 | 8/5/2019 |
4.1.1 | 15,365 | 5/20/2019 |
4.0.3 | 805 | 4/15/2019 |
2.9.1 | 3,088 | 3/15/2019 |
2.8.0 | 530 | 3/5/2019 |
2.7.2 | 613 | 1/29/2019 |
2.7.1 | 445 | 1/28/2019 |
2.6.19 | 506 | 1/9/2019 |
2.6.18 | 469 | 12/28/2018 |
2.6.17 | 4,150 | 12/3/2018 |
2.6.15 | 789 | 11/5/2018 |
2.6.13 | 860 | 10/24/2018 |
2.4.13 | 434 | 10/22/2018 |
2.4.12 | 1,297 | 9/21/2018 |
2.4.11 | 662 | 8/17/2018 |
2.4.10 | 12,144 | 5/14/2018 |
2.4.9 | 1,363 | 4/10/2018 |
2.4.8 | 498 | 2/27/2018 |
2.4.7 | 581 | 11/6/2017 |
2.4.6 | 474 | 9/12/2017 |
2.4.5 | 567 | 4/27/2017 |
2.4.4 | 456 | 3/13/2017 |
2.4.3 | 503 | 1/10/2017 |
2.4.2 | 424 | 1/10/2017 |
2.4.1 | 445 | 12/29/2016 |
2.3.9 (current version) | 444 | 12/14/2016 |
2.3.8 | 452 | 11/14/2016 |
2.3.7 | 424 | 11/14/2016 |
2.3.6 | 435 | 11/3/2016 |
2.3.5 | 422 | 11/3/2016 |