ArieGato / serilog-sinks-rabbitmq

Serilog Sink for RabbitMq
Apache License 2.0
53 stars 51 forks source link

Add support for dynamic routing keys #105

Closed maxdeviant closed 4 years ago

maxdeviant commented 4 years ago

This PR adds support for building routing keys dynamically based on the log event.

When configuring the sink you can provide a delegate that receives the LogEvent and then use that event to build a routing key:

// The routing key will be the level of the event (e.g., "Information", "Fatal", etc.).
sinkConfiguration.BuildRoutingKey = logEvent => logEvent.Level.ToString();

If the BuildRoutingKey option is not supplied or returns null then it will use the static RouteKey from the configuration.

Resolves #104.