Simple Powershell Logging Module
Install from the PSGallery and Import the module
Install-Module PowerLumber
Import-Module PowerLumber
For more information
This project was generated using Kevin Marquette's Full Module Plaster Template.
This powershell module includes commands to assist with logging.
Powershell version 5.0 (It may work with older versions, but its not tested.)
Import-Module <path>\PowerLumber.psm1
$webclient = New-Object System.Net.WebClient
$filepath = "C:\temp\PowerLumber.psm1"
$url = "https://raw.github.com/jpsider/PowerLumber/master/PowerLumber.psm1"
$webclient.DownloadFile($url,$filepath)
Import-module $filepath
Clear-LogDirectory
New-Log
Write-Log
Invoke-RollLog
Write-LogLevel
New-Log -logfile c:\temp\new.log
Clear-LogDirectory -Path "c:\temp" -DaysBack 3
Write-Log -Message "I love lamp" -Logfile "C:\temp\mylog.log" -OutputStyle noConsole
Write-Log -Message "I love lamp" -Logfile "C:\temp\mylog.log" -OutputStyle both
Write-Log -Message "I love lamp" -Logfile "C:\temp\mylog.log" -OutputStyle consoleOnly
Write-Log -Message "I love lamp" -Logfile "C:\temp\mylog.log"
Write-Log -Message "I love lamp" -OutputStyle consoleOnly
-RunLogLevel is meant to be a system/script wide Level
-MsgLevel is meant to be for a specific Log Message
This Module will only write Equal or Lower LogLevels based on the Message Level compared to the -RunLogLevel
Write-LogLevel -Message "I love lamp" -Logfile "C:\temp\mylog.log" -RunLogLevel All -MsgLevel TRACE
Setting -RunLogLevel to CONSOLEONLY will not write any messages, all log messages will be displayed to the console
Write-LogLevel -Message "I love lamp" -Logfile "C:\temp\mylog.log" -RunLogLevel CONSOLEONLY -MsgLevel CONSOLEONLY
Write-LogLevel -Message "I love lamp" -Logfile "C:\temp\mylog.log" -RunLogLevel WARN -MsgLevel WARN
Write-LogLevel -Message "I love lamp" -Logfile "C:\temp\mylog.log" -RunLogLevel FATAL -MsgLevel DEBUG