In my ASP.NET Core application, I have configured the ILoggerFactory
instance to output logs in Application Insights:
public class Startup
{
...
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(LogLevel.Debug);
loggerFactory.AddDebug();
// By default, set the minimum severity level to Information.
loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Information);
// ...
}
}
Later, someClass
is being injected the ILoggerFactory
instance and it is logging a Debug message:
public class SomeClass
{
private ILogger _logger;
public SomeClass(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger(nameof(SomeClass));
}
public void Do()
{
_logger.LogDebug($"Some debug message");
}
}
Application Insights is configured separately from the ASP.NET Core app, not as an extension.
Since I have configured Application Insights to only log message with a severity higher than or equal to Informational message, I do not see the Debug traces.
Question
Is there a way to change the minimum logging level from the Azure Portal for troubleshooting purposes without having to recompile the application?