My web job is not adhering to the logging level configuration in my host.json. It is written using .NET framework 4.7. The expected result with the below code is no logging, instead, I get logging a per the below screenshot. Can any provide guidance on how to fix this? Do I need to add additional configuration/startup code?
host.json
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"Functions.Test": "None",
"default": "None"
}
}
}
C# Web Job Code
public static void Main()
{
var config = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("host.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
var builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddTimers();
b.AddBuiltInBindings();
});
builder.ConfigureLogging((context, b) =>
{
b.AddConsole();
});
var host = builder.Build();
using (host)
{
var jobHost = host.Services.GetService(typeof(IJobHost)) as JobHost;
jobHost.CallAsync("Test").GetAwaiter().GetResult();
}
}
}
public class Functions
{
[NoAutomaticTrigger]
public static void Test(ILogger logger)
{
logger.LogCritical("LogCritical");
logger.LogDebug("LogDebug");
logger.LogError("LogError");
logger.LogInformation("LogInformation");
logger.LogTrace("LogTrace");
logger.LogWarning("LogWarning");
Thread.Sleep(1000 * 10);
}
}
}