Closed vksv closed 2 months ago
You can disable logging at all for Kernel Memory by setting the logging minimum level of its LoggerFactory
:
Microsoft.KernelMemory.Diagnostics.DefaultLogger.Factory = LoggerFactory.Create(builder =>
{
builder.SetMinimumLevel(LogLevel.None);
});
If you don't have to disable all the logging, you can use the builder
parameter to configure logging destinations and their settings in a more granular way.
With memory builder you can use this:
var builder = new KernelMemoryBuilder()
.Configure(builder => builder.Services.AddLogging(l =>
{
l.SetMinimumLevel(LogLevel.None);
}))
...
or this, if you want to see errors:
var builder = new KernelMemoryBuilder()
.Configure(builder => builder.Services.AddLogging(l =>
{
l.SetMinimumLevel(LogLevel.Error);
l.AddSimpleConsole(c =>
{
c.SingleLine = true;
c.UseUtcTimestamp = false;
c.TimestampFormat = "[HH:mm:ss.fff] ";
});
}))
...
You could also log to file, see here for example https://learn.microsoft.com/en-us/answers/questions/1377949/logging-in-c-to-a-text-file
As @marcominerva mentioned, you can configure a lot of other options.
Context / Scenario
I am getting the below console logging when executing windows C# (.NET6.0) console applications built using
kernel-memory
. How do I configure so I don't get them? I have set thelogger = null
for both thekernel
andkernel-memory
. It didn't help. I have changed configurations between Release vs Debug. It didn't help. This interferes with my console application output.What happened?
No console logging to happen after setting the
logger = null
for both thekernel
andkernel-memory
Importance
I cannot use Kernel Memory
Platform, Language, Versions
C#, .NET6.0, Windows Console Application
Relevant log output