Protokollierung von HTTP in Datei, jedoch nicht in der Datenbank mit Serilog

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Protokollierung von HTTP in Datei, jedoch nicht in der Datenbank mit Serilog

by Guest » 24 Feb 2025, 02:20

Ich habe eine ASP.NET -Kern -Web -API, in der ich Serilog zur Protokollierung verwende. .Httplogging.httploggingMiddleware in der Protokoll-Datei, aber in der Datenbank möchte ich nur Warnung aus protokollieren Microsoft.aspnetcore.httplogging.httploggingMiddleware .
Ein einfacher Weg dazu? aber es logt sich microsoft.aspnetcore.htttlogging.httploggingMiddleware in die Datenbank ab.

Code: Select all

    "Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Sinks.MSSqlServer" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Information"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "Logs/log.txt",
"rollingInterval": "Day"
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "....",
"restrictedToMinimumLevel": "Information"
// More configuration options
}
}
]
}

Top