Last active
April 30, 2020 12:36
-
-
Save CoreProgramm/b111c739c7b2cf95292902f5632b60da to your computer and use it in GitHub Desktop.
CustomLoggerMiddleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomLoggerMiddleware | |
{ | |
private readonly RequestDelegate _next; | |
private readonly ILogger _logger; | |
public CustomLoggerMiddleware(RequestDelegate next, ILoggerFactory logFactory) | |
{ | |
_next = next; | |
_logger = logFactory.CreateLogger("MyMiddleware"); | |
_logger.LogInformation("MyMiddleware is Started"); | |
} | |
public async Task Invoke(HttpContext httpContext) | |
{ | |
_logger.LogInformation("MyMiddleware is executing.."); | |
await _next.Invoke(httpContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment