Created
February 10, 2014 11:17
-
-
Save nblumhardt/8914175 to your computer and use it in GitHub Desktop.
An alternative to stack walking to add caller names to Serilog events
This file contains hidden or 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 static class LoggerExtensions | |
{ | |
public static ILogger ForHere( | |
this ILogger logger, | |
[CallerFilePath] string sourceFile = null, | |
[CallerLineNumber] int sourceLine = 0) | |
{ | |
return logger | |
.ForContext("SourceFile", sourceFile) | |
.ForContext("SourceLine", sourceLine); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment