Serilog ausschließen DatenbankabfrageprotokollC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Serilog ausschließen Datenbankabfrageprotokoll

Post by Anonymous »

Ich habe meine SQL -Datenbankprotokolle vor Konsolen/Debuggen ausgeblendet, indem ich diese Codezeile im Programm hinzufügte.cs :

Code: Select all

builder.Host.UseSerilog((builderContext, config) =>
{
config.ReadFrom.Configuration(builderContext.Configuration);
config.Filter.ByExcluding(Matching.FromSource("Microsoft.EntityFrameworkCore.Database.Command"));
});
< /code>
Wie verbergte ich meine SQL -Abfragen mit der Datei appSettings.json? < /p>
"Serilog": {
"MinimumLevel": {
"Default": "Information"
},
"WriteTo": [
{
"Name": "Console",
"Args": { "outputTemplate": "[{Timestamp:dd/MM/yyyy HH:mm:ss ffff zzz} {Level:u3}] {Message:lj}{NewLine}{Exception}" }
},
{
"Name": "Debug",
"Args": { "outputTemplate": "[{Timestamp:dd/MM/yyyy HH:mm:ss ffff zzz} {Level:u3}] {Message:lj}{NewLine}{Exception}" }
},
],
// Tried this but it does not work.
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"expression": "SourceContext = 'Microsoft.EntityFrameworkCore.Database.Command'"
}
}
],
"Enrich": [
"FromLogContext"
]
},

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post