Logging

2.4.13

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.13

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

Install-PSResource -Name Logging -Version 2.4.13

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 235,221 3/23/2022
4.8.3 44,760 10/6/2021
4.8.2 65,056 3/15/2021
4.8.1 5,883 2/18/2021
4.8.0 1,904 2/11/2021
4.7.1 445 2/11/2021
4.5.0 9,484 10/22/2020
4.4.0 8,091 6/17/2020
4.3.2 850 5/28/2020
4.3.1 449 5/28/2020
4.2.13 6,353 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,048 3/15/2019
2.8.0 530 3/5/2019
2.7.2 612 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 (current version) 434 10/22/2018
2.4.12 1,297 9/21/2018
2.4.11 662 8/17/2018
2.4.10 12,129 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 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
Show less