-
-
Save phaufe/e6740155698d28fb72e1894bd5efd686 to your computer and use it in GitHub Desktop.
Using Serilog in a PowerShell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -Path "Serilog.dll" | |
Add-Type -Path "Serilog.Sinks.Seq.dll" | |
Add-Type -Path "Serilog.Sinks.EventLog.dll" | |
Add-Type -Path "Serilog.FullNetFx.dll" | |
Add-Type -Path "Serilog.Extras.AppSettings.dll" | |
Add-Type -Path "Serilog.Extras.Timing.dll" | |
$Config = New-Object Serilog.LoggerConfiguration | |
[Serilog.Configuration.LoggerSinkConfiguration]$ConfigSink = $config.WriteTo | |
[Serilog.Log]::Logger = [Serilog.LoggerConfigurationFullNetFxExtensions]::RollingFile($ConfigSink, "C:\Logs\Log-{Date}.txt", ([Serilog.Events.LogEventLevel]::Verbose), "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}", $null, 10000000, 15).CreateLogger() | |
[Serilog.Log]::Information("Logging started") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment