Skip to content

REQUESTS - Performance Logging

Ever wanted to track and log how long your requests take to process? Maybe even have an error logged if a call is passing a certain threshold? The PerformanceLogging middleware is designed to help you with this.

Internally, the middleware will log the time it takes to process a request to your logging setup. If the error threshold is passed, it will log an error otherwise it will log to Debug.

We recommend focusing timed logging on your most critical requests. Logging every request can be a performance hit.

Setup

In your host startup, add the following to your mediator configuration:

services.AddShinyMediator(cfg => cfg.UsePerformanceLogging());

Configuration

{
"Mediator": {
"PerformanceLogging": {
"My.Contracts.*": {
"ErrorThresholdMilliseconds": 1000
}
}
}
}