Skip to content

Instantly share code, notes, and snippets.

@gcollic
Last active May 17, 2018 15:25
Show Gist options
  • Save gcollic/0ce7c775efe125555c6cc6e796f36844 to your computer and use it in GitHub Desktop.
Save gcollic/0ce7c775efe125555c6cc6e796f36844 to your computer and use it in GitHub Desktop.
Trying Serilog in LinqPad ( gist version of https://twitter.com/adamchester/status/726965534693056513 )
void Main()
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Warning()
.Enrich.FromLogContext()
.Enrich.WithProperty("url", "http://serilog.net/")
.WriteTo.Sink(new LinqpadDumpSink())
.CreateLogger();
Log.Warning(
"Processing inside {@test}, something weird happened",
typeof(Int32).GetMethod("GetTypeCode"));
}
class LinqpadDumpSink : Serilog.Core.ILogEventSink
{
public void Emit(LogEvent @event)
{
@event.RenderMessage().Dump();
new {
Basiclnfo = new
{
@event.Level,
@event.MessageTemplate.Text
},
@event.Properties,
@event.Exception,
}.Dump();
}
}
@afluegge
Copy link

Cool. Very helpful. Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment