Skip to content
Projects

About

:nut_and_bolt: PoShLog is a cross-platform PowerShell logging module. It makes it easy to log structured event data to the console, files, and many other destinations. It is built on the Serilog C# logging library: https://serilog.net/

Developer Tools

How these counts are measured

Measured star growth

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

PoShLog: structured logging for PowerShell, built on Serilog

CI PowerShell Gallery version PowerShell Gallery downloads PowerShell 7.6+ MIT license Discord

Write structured log events from PowerShell to the console, files, Seq, OpenTelemetry, Elasticsearch, Splunk, syslog and more.

Quick start · Sinks · Documentation · v2 or v3? · Changelog

[!NOTE] PoShLog 3 is in preview. It is a compiled module for PowerShell 7.6+ on Windows, Linux and macOS. Install it with -AllowPrerelease. On Windows PowerShell 5.1, use the maintained v2 line.

Why PoShLog

  • Structured, not just text. Messages are templates: {Count} stays a number that Seq, Splunk or any log backend can filter and chart.
  • One logger, many destinations. Send the same events to the console, a rolling file and a log server, each with its own minimum level and format.
  • Built on Serilog 4. You get its levels, enrichers and formatters, and Serilog 4 sink packages can be configured directly as an advanced route (migration guide).
  • Fast and familiar. A compiled binary module with the same cmdlet names and parameters as v2.

Quick start

Install-Module PoShLog -AllowPrerelease

Start-Logger -Console -FilePath './logs/app.log'

Write-InfoLog 'Copied {Count} files to {Target}' -PropertyValues 42, 'D:\Backup'

Close-Logger

Console output of the quick start, and the same event as structured data

Need more control? Build the logger as a pipeline: one minimum level, several sinks, each with its own settings.

New-Logger |
    Set-MinimumLevel -Value Verbose |
    Add-SinkConsole |
    Add-SinkFile -Path './logs/app-.log' -RollingInterval Day |
    Add-SinkSeq -ServerUrl 'http://localhost:5341' |    # Install-Module PoShLog.Sinks.Seq
    Start-Logger

Write-VerboseLog 'Starting backup of {Path}' -PropertyValues 'C:\Data'
Write-WarningLog 'Disk {Drive} is {Percent}% full' -PropertyValues 'D:', 91
Write-ErrorLog 'Backup failed' -ErrorRecord $Error[0]

Close-Logger

How it works

A script writes a message template; PoShLog, on the Serilog pipeline, sends the event to every configured sink

Sinks

Console, File and the PowerShell streams are built into PoShLog. Everything else is a small extension module you install next to it.

Destination Module Install Docs
Console, File, PowerShell streams PoShLog built in Add-SinkConsole, Add-SinkFile, Add-SinkPowerShell
OpenTelemetry (OTLP): Grafana, .NET Aspire, Datadog, Elastic, any Collector PoShLog.Sinks.OpenTelemetry Install-Module PoShLog.Sinks.OpenTelemetry Add-SinkOpenTelemetry
Seq PoShLog.Sinks.Seq Install-Module PoShLog.Sinks.Seq Add-SinkSeq
Splunk HTTP Event Collector PoShLog.Sinks.Splunk.Hec Install-Module PoShLog.Sinks.Splunk.Hec Add-SinkSplunk
Syslog (RFC 5424 / 3164 over UDP, TCP, TLS) PoShLog.Sinks.Syslog.Rfc5424 Install-Module PoShLog.Sinks.Syslog.Rfc5424 Add-SinkSyslog
Elasticsearch and Elastic Cloud (data streams, ECS) PoShLog.Sinks.Elastic Install-Module PoShLog.Sinks.Elastic Add-SinkElasticsearch
HTTP endpoints PoShLog.Sinks.Http Install-Module PoShLog.Sinks.Http Add-SinkHttp
Windows Event Log PoShLog.Sinks.EventLog Install-Module PoShLog.Sinks.EventLog Add-SinkEventLog
Enrichers: environment, process, exception details PoShLog.Enrichers Install-Module PoShLog.Enrichers Enrichers

PoShLog can list and install its extensions itself. Install-PoShLogExtension adds -Prerelease while PoShLog 3 is in preview, so you do not have to:

Get-PoShLogExtension | Format-Table      # name, kind, version, installed version, commands
Get-PoShLogExtension -Online             # adds the latest version in the Gallery
Install-PoShLogExtension PoShLog.Sinks.Seq

Without it, install the extensions with Install-PSResource <module> -Prerelease while PoShLog 3 is in preview (compatibility page, Get-PoShLogExtension, Install-PoShLogExtension). Third-party modules and other Serilog sinks are listed on the sinks page.

v2 or v3?

PoShLog 3 (preview) PoShLog 2
PowerShell 7.6+ on Windows, Linux, macOS Windows PowerShell 5.1 and PowerShell 7
Module compiled, Serilog 4 script module, Serilog 2
Install Install-Module PoShLog -AllowPrerelease Install-Module PoShLog -MaximumVersion 2.99
Status new features bug fixes and Serilog updates

Moving a script over? Read v2 or v3? and the migration guide.

Documentation

Contributing

Pull requests are welcome. For bigger changes, please open an issue or a discussion first. Good first issues are a nice place to start, and the developer guide explains the layout.

Building locally

You need the .NET 10 SDK (or newer) and PowerShell 7.6+.

dotnet build PoShLog.sln
dotnet publish src/dotnet/PoShLog.Core.csproj -o src/lib
dotnet test PoShLog.sln
Invoke-Pester ./tests

Import-Module ./src/PoShLog.psd1
Start-Logger -Console
Write-InfoLog 'Hello from PoShLog!'
Close-Logger

Show your support

  • ⭐ Star the repository. It is the simplest way to help the project.
  • 💬 Share feedback and ideas in Discussions or on Discord.
  • 🐞 Try the preview and report issues.

Authors and contributors

Created and maintained by Tomáš Bouda, with contributions from Michael Zimmerli, Martin Dennhardt, Brady Shober and Chris Hunt.

License

PoShLog is licensed under the MIT License. The logo and graphics in docs/assets are part of this project and covered by the same license.

Credits

Explore related projects

Loading…