-
-
Save andymac4182/904e4ee3cf92f760a3a3641d102466ea to your computer and use it in GitHub Desktop.
Trying Serilog in LinqPad ( gist version of https://twitter.com/adamchester/status/726965534693056513 )
This file contains 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
void Main() | |
{ | |
Log.Logger = new LoggerConfiguration() | |
.MinimumLevel.Warning() | |
.Enrich.FromLogContext() | |
.Enrich.WithProperty("url", "http://serilog.net/") | |
.WriteTo.Sink(new LingpadDumpSink()) | |
.CreateLogger(); | |
Log.Warning( | |
"Processing inside {@test}, something weird happened", | |
typeof(Int32).GetMethod("GetTypeCode")); | |
} | |
class LingpadDumpSink : Serilog.Core.ILogEventSink | |
{ | |
public void Emit(LogEvent @event) | |
{ | |
new { | |
Basiclnfo = new | |
{ | |
@event.Level, | |
@event.MessageTemplate.Text | |
}, | |
@event.Properties, | |
@event.Exception, | |
}.Dump(@event.RenderMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment