How do I remove unnecessary information in Serilog logs? The docs seem to have nothing about this.
I want to remove the red part in the image above
This is my config in appsettings.json
"Serilog": {
"Using": [ "Serilog.Settings.Configuration" ],
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "@Level in ['Debug']"
}
}
],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"System": "Debug",
"Microsoft": "Debug"
}
},
"WriteTo": [
{
"Name": "Seq",
"Args": {
"serverUrl": "http://localhost:5341/",
"compact": true
}
},
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"path": "D:\\dev.SmartCity.Peafowls.Logs\\PeafowlsLog_.txt",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"fileSizeLimitBytes": 4194304
}
}
] }
CodePudding user response:
Its not completly clear what you want. I can only assume, that you want to display only the Log-Message to the console.
To achieve that, you can add the following outputTemplate to your block:
{
"Name": "Console",
"Args": {
"outputTemplate": "{Message}{NewLine}"
}
}
CodePudding user response:
The problem was that i had this line in the startup class when initializing the logger. .WriteTo.Providers(providers)
This is my configuration now:
private void ConfigureLogging(ServiceProvider services, LoggerProviderCollection providers)
{
var configuration = services.GetRequiredService<IConfiguration>();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.Destructure.ByTransforming<ExpandoObject>(e => new Dictionary<string, object>(e))
.Enrich.WithProperty("Source", "Peafowls")
#if DEBUG || STAGE
.Enrich.WithProperty("Environment", _env)
#endif
.CreateLogger();
}