I am using Serilog with .NET 6.0. I can set the LogLevel
in appsettings.json
to allow only certain type of logs.
But I need to write only the log messages explicitly written by my code.
For example: if I have set LogLevel
to Information
, and in the controller method I am writing one line to the Log:
logger.LogInformation(1, "Test message for Information Level.");
when it runs I can see this message in DB, but there are also other messages generated by system. I don't need that system-generated messages in my table.
How can I log the messages only written by application code?
Set "Microsoft" logging level > Default logging level
By program.cs (Serilog.AspNetCore)
or appsettings.json
Logging level: Verbose-0, Debug-1, Information-2, Warning-3, Error-4, Fatal-5.