I have a small console app. I have enabled Debug and Console logging. However, they do not seem to be honouring my config for log level. Here is my setup:
Add Config file and create logger
// global to Program
private static ILogger<Program> _logger;
private const string _configFile = "appsettings.json";
//inside Main
_config = new ConfigurationBuilder()
.AddJsonFile(_configFile, optional: false, reloadOnChange: true)
//.AddEnvironmentVariables()
.AddCommandLine(args)
.Build();
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddDebug();
builder.AddSimpleConsole();
});
_logger = loggerFactory.CreateLogger<Program>();
appconfig.json
"Logging": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Debug",
"Microsoft": "Warning"
},
"Debug": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Warning",
"FleetLogix.TcaProcessor": "Trace"
}
},
"SimpleConsole": {
"IncludeScopes": "false",
"SingleLine": "false",
"TimestampFormat": "yyyy-MM-dd HH:mm:ss ",
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"FleetLogix.TcaProcessor": "Information"
}
}
},
Its currently set to log to two providers, Debug (visual studio run pane) and Console. This is working. Debug is meant to log at Trace, but is only logging at Info. Console is logging at Info, but is not prefixing the timestamp onto the messages.
Is my config setup correctly? (correct property names, correct depth, etc) What should I change it to?
Console also has the awful line break that reading tells me you need to fork Microsoft.Extensions.Logging.Console to fix, so another day. :/