29 lines
912 B
C#
29 lines
912 B
C#
namespace LFlow.Middleware.Middlewares
|
|
{
|
|
public class LoggingMiddleware : ILFlowMiddleware
|
|
{
|
|
private readonly ILogger<LoggingMiddleware> _logger;
|
|
|
|
public LoggingMiddleware(ILogger<LoggingMiddleware> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public int Priority => 1;
|
|
|
|
public async Task RunAsync(HttpContext context, Func<Task> next)
|
|
{
|
|
var controllerName = context.GetRouteData()?.Values["controller"]?.ToString();
|
|
var actionName = context.GetRouteData()?.Values["action"]?.ToString();
|
|
|
|
using (_logger?.BeginScope("LoggingMiddleware"))
|
|
{
|
|
//_logger?.LogInformation($"Controller: {controllerName} / Action : {actionName}");
|
|
//_logger?.LogInformation("Router Data {@routerData}", context.GetRouteData());
|
|
await next();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|