Project is not maintained as all the features can be found in the excellent & more advanced Serilog Expressions.
Serilog extra that adds a fluent API to configure rules for modifying properties on the fly and piping events to secondary loggers.
Add/Remove/Update properties based on a criteria.
var log =
new LoggerConfiguration()
.WriteTo.Trace()
.Enrich.With<HttpRequestEnricher>()
// We need to remove the RawUrl property if there is a payment
// processing error otherwise we may expose the credit card in the logs.
.When().IsExceptionOf<CreditCardPaymentException>().Do().RemovePropertyIfPresent("RawUrl")
// When the the Special Service fails, log the current endpoint
.When().IsExceptionOf<SpecialServiceException>().Do().AddOrUpdateProperty("SpecialServiceEndpoint", _settings.SpecialServiceEndpoint, true)
// If one of the two possible properties is there, remove "UnnecessaryProperty"
.When().HasProperty("PossibleProperty", "PossiblePropertyOther").Do().RemovePropertyIfPresent("UnnecessaryProperty")
.CreateLogger();
SendTo sends a copy of an event to another logger if the critiera matches. PipeTo only sends the event to another logger if the criteria matches.
var backupLogger = new LoggerConfiguration().WriteTo.Trace.CreateLogger();
var specialLogger = new LoggerConfiguration().WriteTo.SpecialSink().CreateLogger();
var log =
new LoggerConfiguration()
.WriteTo.Trace()
// Sends a copy of the event to the backupLogger --
// both loggers will get the same event.
.When().FromSourceContext<AccountingService>().Do().SendTo(backupLogger)
// Pipes all events that match criteria to the specialLogger.
// "this" logger will not receive the event.
.When().FromSourceContext<ChattyService>().Do().PipeTo(specialLogger)
.CreateLogger();
Copyright "Solution" by Arthur Shlain from the Noun Project