Is there a simple way to log (using nlog, e.g. log.Debug(…)
) the selected route in an ASP.NET Core MVC application? I use HttpGet
/HttpPost
attributes to define my routes, and I am looking for a simple way to log the route that MVC chooses to handle for each incoming request.
Note: Similar questions have been answered, but they relate to debugging and analyzing routes:
For my purposes, though, I just want to know which route MVC chose to handle for the request and have it logged. (And, ideally, I don't want to add a log to each controller method; there must be some way to do this once generically for all incoming requests.)