I am trying to log elapsed time for each request(.net core 2.2) in my configure method like this:
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
app.Use(async (context, next) =>
{
Logging.Log.Id = Convert.ToString(new Activity(string.Empty).Id);
var sw = new Stopwatch();
sw.Start();
await next.Invoke();
sw.Stop();
Logging.Log.Info($"ElapsedTime: {sw.ElapsedMilliseconds}");
});
// rest of method code omitted
}
Along with elapsed time I want to display which endpoint was called or absolute uri where the request is headed to. How can I get the same here from context object.