Code: Select all
Microsoft.Extensions.Logging
Einige Funktionen in Serilogs Serilog.ILogger sind in MELs ILogger nicht verfügbar oder sind verfügbar, aber äußerst ausführlich.
Ich möchte ein Protokollereignis anreichern. Mit Serilog würde ich Folgendes verwenden:
Code: Select all
_logger
.ForContext("Foo", "abc")
.ForContext("Bar", 123)
.ForContext("Baz", true)
.Information("Process returned {Result}", 42);
Code: Select all
using (_logger.BeginScope(new Dictionary {
{ "Foo", "abc" },
{ "Bar", 123 },
{ "Baz", true }
})) {
_logger.LogInformation("Process returned {Result}", 42);
}
Mir ist aufgefallen, dass es für solche Dinge zusätzlich zu den oben genannten noch verschiedene Syntaxen gibt. Gibt es eine einfachere Option?