Save MiniProfiler results into a Microsoft.Extensions.Logging logger.
Save MiniProfiler results into a Microsoft.Extensions.Logging logger.
To get started install the MiniProfilerContrib.Logging package:
PM> Install-Package MiniProfilerContrib.Logging
or
dotnet add package MiniProfilerContrib.Logging
The LoggerStorage
can accept an ILoggerFactory
or ILogger<MiniProfiler>
. These can be retrieved through dependency injection or by bootstrapping a logger factory.
var loggerFactory = LoggerFactory.Create(builder =>
builder
.AddConsole()
.AddDebug()
.SetMinimumLevel(LogLevel.Trace));
var logger = loggerFactory.CreateLogger<MiniProfiler>()
Then, setup the MiniProfiler
using a LoggerStorage
, passing along the logger as well as the logging level the profiler output will be (default LogLevel.Debug
).
MiniProfiler.Configure(new MiniProfilerOptions
{
Storage = new LoggerStorage(logger)
});
And you can continue to use MiniProfiler as usual.
See the MiniProfiler documentation and the
samples
folder for working examples.
MIT