Logging

2.4.12

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\exam
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

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name Logging -RequiredVersion 2.4.12

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name Logging -Version 2.4.12

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2015 Massimo Bonvicini. All rights reserved.

Package Details

FileList

Version History

Version Downloads Last updated
4.8.5 163,960 3/23/2022
4.8.3 44,575 10/6/2021
4.8.2 65,034 3/15/2021
4.8.1 5,880 2/18/2021
4.8.0 1,901 2/11/2021
4.7.1 442 2/11/2021
4.5.0 9,481 10/22/2020
4.4.0 8,083 6/17/2020
4.3.2 847 5/28/2020
4.3.1 446 5/28/2020
4.2.13 6,208 2/25/2020
4.2.12 1,609 11/8/2019
4.2.11 774 9/23/2019
4.2.7 448 9/19/2019
4.2.6 473 9/13/2019
4.2.3 538 8/27/2019
4.2.2 684 8/5/2019
4.1.1 15,360 5/20/2019
4.0.3 802 4/15/2019
2.9.1 2,815 3/15/2019
2.8.0 527 3/5/2019
2.7.2 609 1/29/2019
2.7.1 441 1/28/2019
2.6.19 503 1/9/2019
2.6.18 466 12/28/2018
2.6.17 4,147 12/3/2018
2.6.15 786 11/5/2018
2.6.13 857 10/24/2018
2.4.13 431 10/22/2018
2.4.12 (current version) 1,294 9/21/2018
2.4.11 659 8/17/2018
2.4.10 11,606 5/14/2018
2.4.9 1,360 4/10/2018
2.4.8 495 2/27/2018
2.4.7 578 11/6/2017
2.4.6 471 9/12/2017
2.4.5 564 4/27/2017
2.4.4 453 3/13/2017
2.4.3 500 1/10/2017
2.4.2 421 1/10/2017
2.4.1 442 12/29/2016
2.3.9 441 12/14/2016
2.3.8 449 11/14/2016
2.3.7 421 11/14/2016
2.3.6 432 11/3/2016
2.3.5 419 11/3/2016
Show less