Skip to content

Instantly share code, notes, and snippets.

@gkinsman
Created February 13, 2020 12:16
Show Gist options
  • Save gkinsman/8b2f7979f14b62b064549dcb4dbc1fbb to your computer and use it in GitHub Desktop.
Save gkinsman/8b2f7979f14b62b064549dcb4dbc1fbb to your computer and use it in GitHub Desktop.
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