using MediatR.Pipeline; using Microsoft.Extensions.Logging; namespace Application.Common.Behaviours; public class LoggingBehaviour : IRequestPreProcessor where TRequest : notnull { private readonly ILogger logger; // ReSharper disable once ContextualLoggerProblem public LoggingBehaviour(ILogger logger) { this.logger = logger; } public Task Process(TRequest request, CancellationToken cancellationToken) { var requestName = typeof(TRequest).Name; logger.LogInformation("Received request: {RequestName}, content: {Request}", requestName, request); return Task.CompletedTask; } }