Skip to content

Instantly share code, notes, and snippets.

@andymac4182
Forked from gcollic/SerilogLinqpad.cs
Last active May 5, 2016 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andymac4182/904e4ee3cf92f760a3a3641d102466ea to your computer and use it in GitHub Desktop.
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 )
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