Created
February 13, 2020 12:16
-
-
Save gkinsman/8b2f7979f14b62b064549dcb4dbc1fbb to your computer and use it in GitHub Desktop.
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 ExceptionFingerprintEnricher : ILogEventEnricher | |
{ | |
private const string ThumbprintKey = "ExceptionThumbprint"; | |
private const string TypeKey = "ExceptionType"; | |
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) | |
{ | |
if (logEvent.Exception == null) return; | |
var fingerprint = ExceptionFingerPrinter.GetFingerprint(logEvent.Exception); | |
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(ThumbprintKey, fingerprint)); | |
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(TypeKey, logEvent.Exception.GetType())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment