Simple way to log all failed route requests in .NET core

 Add this simple middleware:

app.Use(async (context, next) =>
 {

   
     await next();

        if (context.Response.StatusCode == 404)
        {
            /* Log the context data */
        }
 });

Post a Comment

Previous Post Next Post