I've been trying to get MiniProfiler.AspNetCore to work with Serilog.AspNetCore, or otherwise be able to log calls.
I tried creating a middleware with EndInvoke
calling
private void EndInvoke(HttpContext context)
if (MiniProfiler.Current != null)
{
Log.ForContext("MiniProfiler", JsonConvert.DeserializeObject<dynamic>(MiniProfiler.Current.ToJson()))
.Verbose("Completed request in {Timing} ms", MiniProfiler.Current.DurationMilliseconds);
}
I'm trying to set it up similar to https://daveaglick.com/posts/easy-performance-and-query-logging-in-aspnet-with-serilog-and-miniprofiler which was done with the 3.0 not 4.0 version of MiniProfiler, as well as aspnet not aspnetcore.
Edit: Fixed the null issue, I was creating my middleware before the miniprofiler middleware, but it is still not logging to serilog/seq properly.