MetroLog
MetroLog copied to clipboard
Avoid repeated messages in Output window of IDE?
I've noticed when running Debug builds that each enabled logger is sending its output to the Output window in Visual Studio. So you end with double or multiple of the same output e.g. here is the output with both the AddTraceLogger and AddInMemoryLogger configured:
19|2024-04-02T18:16:19.5288469+00:00|TRACE|1|CreateLogger FlyoutMenuViewModel 20|2024-04-02T18:16:19.5308830+00:00|TRACE|1|Created Logger 'FlyoutMenuViewModel' 21|2024-04-02T18:16:19.5320016+00:00|TRACE|1|CreateLogger FlyoutMenuViewModel 22|2024-04-02T18:16:19.5330669+00:00|TRACE|1|Created Logger 'FlyoutMenuViewModel'
This creates extra noise to sort through in the output window. Am I missing something that controls this in the configuration? Or could there be something added to address it?
Here is how I have it configured:
builder.Logging
.SetMinimumLevel(LogLevel.Trace) // IMPORTANT: set the overall minimum log level else individual logger filters may not work
#if DEBUG
.AddTraceLogger(options => // Writes to the Debug output
{
options.MinLevel = LogLevel.Trace;
options.MaxLevel = LogLevel.Critical;
})
#endif
.AddInMemoryLogger(options => // Write to memory in support of displaying events in a UI
{
options.MaxLines = 1024;
options.MinLevel = LogLevel.Debug;
options.MaxLevel = LogLevel.Critical;
});
Actually looking at this now I see the memory logger MinLevel is supposed to be Debug but the output is still showing Trace messages. Hmm.