Skip to main content

PSLogs

This project has adopted the following policies CodeOfConduct Contributing Security

Project status

GitHub Workflow Status Codecov Platform PowerShell Gallery License docs changelog GitHub release (latest SemVer including pre-releases) GitHub release (latest SemVer including pre-releases)

About

PSLogs is a fork of the Logging module created by Massimo Bonvicini. Sadly the project is no longer maintained. In the readme in the original repo the author encourages people to reach out to become the owner of the repo so that it can continue to be developed. I've done this but have not gotten any response. Therefor I have forked the project to continue development of the module.

There are a number of logging modules out there, most of them are quite simple and performs the task of logging to console and file very well. What is different with this module (that I really like) is that the logging target is split up into plugins. Of course there is console and file but a number of other targets like elastic search, email, slack, teams, winevent etc.

I've written a couple of targets myself like SQLite and GELF.

Another reason I really like this logging module is that the logging is disconnected from the script that requests logs to be written. The logging is performed in another thread and therefore the execution of the main script is much less impacted by each logging operation.

Installation

To install from the PowerShell gallery using PowerShellGet run the following command:

Install-Module PSLogs -Scope CurrentUser

Usage

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 'Message n. {0}' -Arguments $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 loosing 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 them)

Configuration

The following section describe how to configure the Logging module.

  • Level
  • Format
  • Targets
  • CustomTargets

Level

There are two aspects of the log level. First the level of each log message and secondly what levels should be logged to the targets. Each target can be configured to a logging level meaning that you might want to log DEBUG and higher to file but only VERBOSE and higher to console. You can also define a default logging level for all targets with Set-DefaultLoggingLevel. This default logging level will be used if logging level is omitted in the target configuration.

Built-in logging levels

* NOTSET    ( 0)
* SQL ( 5)
* DEBUG (10)
* VERBOSE (14)
* INFO (20)
* NOTICE (24)
* SUCCESS (26)
* WARNING (30)
* ERROR (40)
* CRITICAL (50)
* ALERT (60)
* EMERGENCY (70)

Configure default logging level

For example:

> Get-LoggingDefaultLevel                       # Get the default value
NOTSET # NOTSET level
> Set-LoggingDefaultLevel -Level 'ERROR' # Set default level to ERROR
> Get-LoggingDefaultLevel # Get the current global level
ERROR

Configure target logging level

Add-LoggingTarget -Name Console -Configuration @{
Level = 'DEBUG'
}

Format

The Format property defines how the message is rendered.

The default value is: [%{timestamp}] [%{level:-7}] %{message}

Built-in variables

The Log object has a number of attributes that are replaced in the format string to produce the message:

FormatDescription
%{timestamp}Time when the log message was created. Defaults to %Y-%m-%d %T%Z (2016-04-20 14:22:45+02). Take a look at this Technet article about the UFormat parameter, and this Technet article for available [DateTimeFormatInfo]
%{timestamputc}UTC Time when the log message was created. Defaults to %Y-%m-%d %T%Z (2016-04-20 12:22:45+02). Take a look at this Technet article about the UFormat parameter, and this Technet article for available [DateTimeFormatInfo]
%{level}Text logging level for the message (DEBUG, INFO, WARNING, ERROR)
%{levelno}Number logging level for the message (10, 20, 30, 40)
%{lineno}The line number on wich the write occured
%{pathname}The path of the caller
%{filename}The file name part of the caller
%{caller}The caller function name
%{message}The logged message
%{body}The logged body (json format not pretty printed)
%{execinfo}The ErrorRecord catched in a try/catch statement
%{pid}The process id of the currently running powershellprocess ($PID)

After the placeholder name you can pass a padding or a date format string separated by a colon (:):

Padding

If the padding value is negative, the field will be left aligned and padded with spaces on the right:

> Set-LoggingDefaultFormat -Format '[%{level:-7}]'
[DEBUG ]
[INFO ]
[WARNING]
[ERROR ]

If the padding value is positive, the field will be right aligned and padded with spaces on the left:

> Set-LoggingDefaultFormat -Format '[%{level:7}]'
[ DEBUG]
[ INFO]
[WARNING]
[ ERROR]

Date format string

The date format string starts with a plus sign (+) followed by UFormat OR Format ([DateTimeFormatInfo]) parameters. See here for available UFormats, and here for available Formats.

> Set-LoggingDefaultFormat -Format '%{timestamp}'
2016-04-20 13:31:12+02

> Set-LoggingDefaultFormat -Format '%{timestamp:+%A, %B %d, %Y}'
Wednesday, April 20, 2016

> Set-LoggingDefaultFormat -Format '[%{timestamp:+%T:12}]' # You could also use padding and date format string at the same time
[ 13:31:12]

> Set-LoggingDefaultFormat -Format '[%{timestamp:+yyyy/MM/dd HH:mm:ss.fff}]'
[2016/04/20 13:31:12.431]

Caller

By default the caller cmdlet is assumed to be the parent function in the executing stack, i.e., the function directly calling the Write-Log cmdlet. However, there are instances where a wrapper cmdlet is used on top of Write-Log to trigger the logging, thus invalidating the default assumption for the caller.

In these scenarios, it is possible to set the caller scope using Set-LoggingCallerScope, which is shown in the example below along with the usage of a wrapper logging cmdlet.

# Write-CustomLog is the wrapper logging cmdlet
# If the default caller scope is used, it would print 'Write-CustomLog' everytime
# filename has value only if the code below is executed in a script

Add-LoggingTarget -Name Console -Configuration @{Level = 'DEBUG'; Format = '[%{filename}] [%{caller}] %{message}'}
Set-LoggingCallerScope 2

function Write-CustomLog {
[CmdletBinding()]
param(
$Level,
$Message
)

Write-Log -Level $Level -Message $Message
}

function Invoke-CallerFunctionWithCustomLog {
1..5 | ForEach-Object {
# In this example, during execution of Write-Log the numeric scope represents the following:
# 0 - Write-Log scope
# 1 - Write-CustomLog scope (which would be default value)
# 2 - Invoke-CallerFunctionWithCustomLog
Write-CustomLog -Level (Get-Random 'DEBUG', 'INFO', 'WARNING', 'ERROR') -Message 'Hello, World! (With caller scope at level 2)'
}
}

Invoke-CallerFunctionWithCustomLog

Note: A format string starting with a percent symbol (%) will use the UFormat parameter of Get-Date

Targets

The Targets property stores the used logging targets, it's where you define where to route your messages.

Keys of the hashtable depends on the target you are configuring. The module ships with 12 targets but you can write your own for specific usage.

When adding a target with Add-LoggingTarget, the -Configuration parameter accepts a hashtable where additional configuration items can be specified. Each target have its own set of items that can be configured. See the Target specific documentation for further information about the available options.

Console

From version 2.3.3 it supports acquiring lock for issues with git prompt that sometimes gets splitted during output. The mutex name to acquire is ConsoleMtx

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
FormatStringNoDefault FormatDefines a custom format for the target
PrintExceptionBooleanNo$truePrints the stacktrace when an exception object is passed to Write-Log
ColorMappingHashtableNoSee belowOverrides the default color mappings
OnlyColorizeLevelBooleanNo$falseIf set to true, only the level name is colorized instead of the whole log row.
ShortLevelBooleanNo$falseIf true the written level name is trimmed to three chars, ie ERROR -> ERR. This makes the logs more aligned and easier to read.
Default color mappings
LevelColor
SQLMagenta
DEBUGCyan
INFODarkGray
WARNINGYellow
ERRORRed
NOTICEGray
VERBOSEYellow
SUCCESSGreen
CRITICALRed
ALERTRed
EMERGENCYMagenta

Each color will be verified against [System.ConsoleColor]. If it is invalid, an error will appear on the screen along with the original message.

Colorize text manually

PSLogs allows you to freely colorize individual parts of the message or variables in the format string. The following two tokens can be used to configure parts of the strings with color.

  • {StartColor:<color>}
  • {EndColor}

Note that it will only work with OnlyColorizeLevel=$true because if this is $false the whole line is colored which overrides this setting.

You can use it within the message itself:

Write-Log -Level VERBOSE -Message 'This is a verbose {StartColor:Magenta}message{EndColor}'

FormatColorMessage

You can also use it within a format string:

Add-LoggingTarget -Name Console -Configuration @{
OnlyColorizeLevel = $true
Format = '{StartColor:Green}%{timestamp:+yyyy-MM-dd HH:mm:ss}{EndColor} | %{level:-7} | %{message}'
}
Write-Log -Level VERBOSE -Message 'This is a verbose {StartColor:Magenta}message{EndColor}'

FormatColorMessage

Example

Add-LoggingTarget -Name Console -Configuration @{
Level = 'DEBUG'
Format = '[%{timestamp}] [%{level}] %{message}'
PrintException = $false
ColorMapping = @{
'DEBUG' = 'Blue'
'INFO' = 'Green'
'WARNING' = 'Yellow'
'ERROR' = 'Red'
}
OnlyColorizeLevel = $true
ShortLevel = $true
}

Format examples

Logging Formats

File

Configuration options

OptionTypeMandatoryDefaultDescription
PathStringYesN/ASets the file destination. It supports templating like $Logging.Format
PrintBodyBooleanNo$falsePrints body message too
AppendBooleanNo$trueAppend to log file
EncodingStringNoasciiSets the log file encoding
LevelStringNoDefault LevelDefines the lowest logging level to logged
FormatStringNoDefault FormatDefines a custom format for the target
PrintExceptionBooleanNo$truePrints the stacktrace when an exception object is passed to Write-Log
ShortLevelBooleanNo$falseIf true the written level name is trimmed to three chars, ie ERROR -> ERR. This makes the logs more aligned and easier to read.
RotateAfterAmountIntNoN/ASets the amount of files after which rotation is triggered
RotateAmountIntNoN/AAmount of files to be rotated, when RotateAfterAmount is used
RotateAfterDateDateTimeNoN/ARotate after the difference between the current datetime and the datetime of the file(s) are greater then the given timespan
RotateAfterSizeIntNoN/ARotate after the file(s) are greater than the given size in BYTES
CompressionPathStringNoN/APath of archive (*.zip) to create for the rotated files

Example

> Add-LoggingTarget -Name File -Configuration @{
Path = 'C:\Temp\%{+%Y%m%d}.log'
PrintBody = $false
PrintException = $false
Append = $true
Encoding = 'ascii'
Level = 'VERBOSE'
Format = '[%{timestamp}] [%{level}] %{message}'
RotateAfterAmount = <NOTSET>
RotateAmount = <NOTSET>
RotateAfterDate = <NOTSET>
RotateAfterSize = <NOTSET>
CompressionPath = <NOTSET>
}
Rotation/Removal

The word Rotate has caused some confusion, Rotate is more often used to describe when a new log file is generated. In PSLogs and formerly the Logging module, Rotate is more of a Cleanup where old log files are removed. Rotation of log file, in other words, generation of new log files is determined by the log file path and variables used for the folder and/or file name. I would love to change this to Cleanup/Remove instead, but it would be a breaking change.

This module provides the functionality for the file target to remove old log files. To make full use of this functionality, variable data used inside the log path should be encoded, using the previously described format system.

When the file target is initialized, all files are retrieved, which expand the given log path. All internally known placeholders are therefore substituted with wildcard characters. Based upon this list of files a file is removed, if

  • the difference between it's creation and the current data is greater then the specified RotateAfterDate
  • it's size in bytes exceeds RotateAfterSize
  • more than RotateAfterAmount files are present and this file belongs to the oldest max(|Files| - RotateAfterAmount, RotateAmount) files.

The default behavior is to remove the log files. It is however possible, to use the CompressionPath to define an archive for the rotated log files. This requires >= NET4.5 The following placeholders are supported

  • %{timestamp}
  • %{timestamputc} If an archive should already be present, the data is added to that archive.

ElasticSearch

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
ServerNameStringYesN/ASets the ES server name
ServerPortIntYesN/ASets the ES server port
IndexStringYesN/ASets the ES index name to log to. It supports templating like $Logging.Format
TypeStringYesN/ASets the ES type for the message
FlattenBooleanNo$falseTransforms the log hashtable in a 1-D hashtable
HttpsBooleanNo$falseUses HTTPS instead of HTTP in elasticsearch URL if $true
AuthorizationStringNoConverts creds to base64 and adds it to headers.

Example

> Add-LoggingTarget -Name ElasticSearch -Configuration @{
ServerName = 'localhost'
ServerPort = 9200
Index = 'logs-%{+%Y.%m.%d}'
Type = 'log'
Level = 'WARNING'
Flatten = $false
Https = $false
Authorization = 'username:password'
}

$Body = @{source = 'Logging'; host='bastion.constoso.com'; _metadata = @{ip = '10.10.10.10'; server_farm = 'WestEurope'}}
Write-Log -Level 'WARNING' -Message 'Hello, Powershell!' -Body $Body
Example Flatten=$false
{
"_index": "powershell-2018-05-10",
"_type": "doc",
"_id": "6BfJXWMB8moSvzgSbZgo",
"_score": 1,
"_source": {
"body": {
"host": "bastion.constoso.com",
"_metadata": {
"server_farm": "WestEurope",
"ip": "10.10.10.10"
},
"source": "Logging"
},
"levelno": 30,
"timestamp": "2018-05-14T10:34:31+02",
"level": "WARNING",
"message": "Hello, Powershell, No Flatten"
}
}
Example Flatten=$true
{
"_index": "powershell-2018-05-10",
"_type": "doc",
"_id": "6RfJXWMB8moSvzgSeJj_",
"_score": 1,
"_source": {
"source": "Logging",
"server_farm": "WestEurope",
"ip": "10.10.10.10",
"levelno": 30,
"level": "WARNING",
"host": "bastion.constoso.com",
"message": "Hello, Powershell, Flatten",
"timestamp": "2018-05-14T10:34:34+02"
}
}

Slack

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
FormatStringNoDefault FormatDefines a custom format for the target
WebHookStringYesN/ASets the Slack Webhook URI
ChannelStringNoN/AOverrides the default channel of the Webhook
BotNameStringNoN/AOverrides the default name of the bot

Example

> Add-LoggingTarget -Name Slack -Configuration @{
WebHook = 'https://hooks.slack.com/services/xxxx/xxxx/xxxxxxxxxx'
Channel = '#other-channel'
BotName = 'PoshLogging'
Level = 'ALERT'
Format = '[%{timestamp}] [%{level}] %{message}'
}

Email

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
FormatStringNoDefault FormatDefines a custom format for the target
SMTPServerStringYesN/ASMTP server FQDN
FromStringYesN/AFrom address
ToStringYesN/AA string of recipients
SubjectStringNoN/AEmail subject. Supports formatting and expansion
AttachmentsStringNoN/APath to the desired file to attach
CredentialPSCredentialNoN/AIf your server uses authentication
PortIntNo25Set the SMTP server's port
UseSslBooleanNoN/AUse encrypted transport to SMTP server
PrintExceptionBooleanNoN/APrint stacktrace in the body

Example

> Add-LoggingTarget -Name Email -Configuration @{
SMTPServer = 'smtp.contoso.com'
From = 'PSLogs <[email protected]>'
To = '[email protected],[email protected]'
Subject = '[%{level:-7}] %{message}'
Attachments = 'C:\Path\To\StateSnapshot.xml'
Credential = $cred
Level = 'ALERT'
Port = 587
UseSsl = $true
PrintException = $true
}

Seq

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
UrlStringYesN/AUrl to Seq instance
ApiKeyStringNoN/AApi Key to authenticate to Seq
PropertiesHashTableNoN/AHashtable of user defined properties to be added to each Seq message

Example

> Add-LoggingTarget -Name Seq -Configuration @{
Url = <NOTSET>
ApiKey = <NOTSET>
Properties = <NOTSET>
Level = <NOTSET>
}

SQLite

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
DatabaseStringYesN/ASet the database file path
TableNameStringYesN/ASet the table name the logs should be inserted to.
ColumnMappingHashtableNoTimestamp = 'Timestamp'; Level = 'Level'; Source = 'Caller'; Message = 'Message'Overrides what built-in values should be inserted into the table
MessageFormatStringNoOverride the message format
PrintExceptionBooleanNo$falseAppend the exception and stackstrace to the message

Example

Add-LoggingTarget -Name SQLite -Configuration @{
Database = "$PSScriptRoot\Logs.sqlite"
TableName = 'Logs'
ColumnMapping = @{
Timestamp = 'Timestamp'
Severity = 'Level'
Source = 'Caller'
Message = 'Message'
}
Level = 'debug'
}

ColumnMapping for built in variables

Using column mapping the following values can be used out-of-the-box

  • pathname
  • pid
  • body
  • timestamp
  • rawmessage
  • lineno
  • filename
  • caller
  • level
  • timestamputc
  • execinfo
  • message
  • levelno

The key of the ColumnMapping hashtable is the SQL Table column name and the value is one of the above properties.

Custom columns

You can also provide custom values for the logging table by providing a hashtable to the Body parameter. Make sure that the table actually has the columns before trying to log them.

Write-Log -Level 'WARNING' -Message 'Hello' -Body @{PSEdition = $PSEdition}

Setup the database

When you have the dependency module PSSQLite installed you can use the following command to initialize a SQLite database for logging. Modify appropriately.

$Query = @'
CREATE TABLE "Logs" (
"Timestamp" DATETIME NOT NULL,
"Severity" TEXT NOT NULL,
"Source" TEXT NOT NULL,
"Message" TEXT NOT NULL,
"PSEdition" TEXT
);
'@
Invoke-SqliteQuery -DataSource C:\Path\To\logs.sqlite -Query $Query

WinEventLog

Prerequisites

Before you can log events you need to make sure that the LogName and Source exists. This needs to be done only once (run as an Administrator)

> New-EventLog -LogName <NOTSET> -Source <NOTSET>

You can now log to the EventLog from your script

Configuration options

OptionTypeMandatoryDefaultDescription
LogNameStringYesN/AName of the log to which the events are written
SourceStringYesN/AEvent source, which is typically the name of the application that is writing the event to the log
LevelStringNoDefault LevelDefines the lowest logging level to logged

EventID

EventID can be specified as body.

Translated Level

Levels will be translated to valid WinEvent log levels

  • Greated than 40 = Error
  • Between 30 and 39 = Warning
  • Less than 30 = Information

Example

> Add-LoggingTarget -Name WinEventLog -Configuration @{
LogName = 'Application'
Source = 'MyNiceScript'
Level = 'WARNING'
}

Write-Log -Level 'WARNING' -Message 'Hello, {0}!' -Arguments 'Powershell' -Body @{ EventID = 123 }

Teams

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
WebHookStringYesN/ASets the Teams Connector URI
DetailsBooleanNo$truePrints Log message details like PID, caller etc.
ColorsHashTableNoDefaults shown in the exampleMaps log levels to badge colors

Example

> Add-LoggingTarget -Name Teams -Configuration @{
WebHook = 'https://outlook.office.com/webhook/...'
Details = $true
Level = 'ALERT'
Colors = @{
'DEBUG' = 'blue'
'INFO' = 'brightgreen'
'WARNING' = 'orange'
'ERROR' = 'red'
'NOTICE' = 'gray'
'VERBOSE' = 'yellow'
'SUCCESS' = 'green'
'CRITICAL' = 'red'
'ALERT' = 'red'
'EMERGENCY' = 'magenta'
}
}

Write-Log -Level 'WARNING' -Message 'Hello, {0}!' -Arguments 'Powershell' -Body @{source = 'Logging'}

AzureLogAnalytics

Log directly to a Azure Log Analytics Workspace from your script

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
WorkspaceIdStringYesN/AId of the Azure Log Analytics Workspace
SharedKeyStringYes$truePrimary or Secondary Key to access the Azure Log Analytics Workspace
LogTypeStringNoDefaults shown in the exampleCreates a custom LogType in Log Analytics Workspace

Example

Add-LoggingTarget -Name AzureLogAnalytics -Configuration @{
WorkspaceId = '8eda8332-16eb-400b-9f0b-6a21e1c1cf28'
SharedKey = 'w7ZhaGTDtmgxcDJlaMO2YWxza2Rqw7Z1MnlvNDd5MWRsYWpraHNsa2Rhc2Q='
LogType = "Logging"
Level = 'DEBUG'
}

Write-Log -Level 'WARNING' -Message 'Hello, Powershell!' -Body { Computer = $env:COMPUTERNAME }

Gelf

Graylog logging format, used to send rich log messages to a Graylog server or other log management system using the Gelf protocol.

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
ServerStringYesN/ADefines the servername of the Graylog server
PortIntYesN/ADefines the port number of the Gelf Input
HostNameStringNo$env:hostnameDefines the hostname of the server running the script
FormatStringNoDefault FormatDefines a custom format for the target
ProtocolStringNo'TCP'Defines if the Gelf input is UDP or TCP
AdditionalFieldHashtableNo$nullOptionally pass on additional static values for the log item

Example

Add-LoggingTarget -Name Gelf -Configuration @{
Level = 'DEBUG'
Server = 'graylog.contoso.com'
Port = 12202
Hostname = 'scriptserver.contoso.com'
Format = '%{message}'
Protocol = 'UDP'
AdditionalFields = @{
Month = (Get-Date).ToString('MMM')
}
}

Write-Log -Level 'WARNING' -Message 'Hello, Powershell!'

WebexTeams

Post message to Webex

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
FormatStringNoDefault FormatDefines a custom format for the target
BotTokenStringYesN/ADefines the bot token
RoomIDStringYesN/ADefines the room id
IconsHashTableNoSee defaults belowOverride the default icons

Default icons

  • ERROR = '🚨'
  • WARNING = '⚠️'
  • INFO = 'ℹ️'
  • DEBUG = '🔎'

Example

Add-LoggingTarget -Name WebexTeams -Configuration @{
Level = 'DEBUG'
Format = '%{message}'
BotToken = ''
RoomID = ''
Icons = @{
ERROR = '🚨'
WARNING = '⚠️'
INFO = 'ℹ️'
DEBUG = '🔎'
}
}

Write-Log -Level 'WARNING' -Message 'Hello, Powershell!'

CustomTargets

If you write a target plugin by your self you can define a path where the module will look for additional target plugins.

Please consider making a pull request to the PSLogs repo so that the target plugin can be included by default in the module.

> Set-LoggingCustomTarget -Path 'C:\temp\'
> Get-LoggingAvailableTarget
Name Value
---- -----
Console {Configuration, ParamsRequired, Logger}
ElasticSearch {Configuration, ParamsRequired, Logger}
File {Configuration, ParamsRequired, Logger}
Slack {Configuration, ParamsRequired, Logger}
MyCustomTarget {Configuration, ParamsRequired, Logger}

Write-Log

The Write-Log function is main tool to actually write/send each log message. One the targets are configured, Write-Log will queue the log message to be written to all configured targets as long as the minimum Level is reached.

Write-Log accepts the following parameters

  • -Level parameter to define that logs level.
  • -Message parameter defines the actual message to log.
  • -Arguments parameter allows you to use format placeholders in the message like, -Message 'Hello, 0' -Arguments $Username
  • -Body parameter allows you pass additional info the target. Please see the target specific documentation for more information.
  • -ExceptionInfo parameter allows you to pass an Exception object to the target. Targets might process these objects differently.

Contributing

Please use issues system or GitHub pull requests to contribute to the project.

For more information, see CONTRIBUTING

Notes

  • The dispatcher thread starts the first time a Write-Log command is executed and keeps running in the background to dispatch new messages until the module is removed.
  • The runspace code is inspired by the work and research of Boe Prox (@proxb).

License

This project is licensed under the MIT License


Included attributions from orginal repo

Special thanks to:

  • Boe Prox (@proxb) for his work on runspaces