Created
April 1, 2013 05:30
-
-
Save sandcastle/5283376 to your computer and use it in GitHub Desktop.
Proposed mapping layer for serilog.
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
// Single registration | |
Log.Logger = new LoggerConfiguration() | |
.WithConsoleSink() | |
.WithMap(new HttpRequestMessageMap()) | |
.CreateLogger(); | |
// Assembly scan | |
Log.Logger = new LoggerConfiguration() | |
.WithConsoleSink() | |
.WithMapsFromAssembly(typeof(Bootstrapper).Assembly) | |
.CreateLogger(); |
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
public class HttpRequestMessageMap : IPropertyMap<HttpRequestMessage> | |
{ | |
public object Map(HttpRequestMessage property) | |
{ | |
return new | |
{ | |
Uri = property.RequestUri.AbsoluteUri, | |
property.Method, | |
property.Headers | |
} | |
} | |
} |
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
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