Skip to content

Instantly share code, notes, and snippets.

@sandcastle
Created April 1, 2013 05:30
Show Gist options
  • Save sandcastle/5283376 to your computer and use it in GitHub Desktop.
Save sandcastle/5283376 to your computer and use it in GitHub Desktop.
Proposed mapping layer for serilog.
// Single registration
Log.Logger = new LoggerConfiguration()
.WithConsoleSink()
.WithMap(new HttpRequestMessageMap())
.CreateLogger();
// Assembly scan
Log.Logger = new LoggerConfiguration()
.WithConsoleSink()
.WithMapsFromAssembly(typeof(Bootstrapper).Assembly)
.CreateLogger();
public class HttpRequestMessageMap : IPropertyMap<HttpRequestMessage>
{
public object Map(HttpRequestMessage property)
{
return new
{
Uri = property.RequestUri.AbsoluteUri,
property.Method,
property.Headers
}
}
}
interface IPropertyMap<T>
{
object Map(T property);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment