Ist es möglich, das Datum und die Uhrzeit im Konsolenprotokoll eines asp.net Core 2.0-Projekts für die Produktions- und Entwicklungsumgebung anzugeben?Datum und Uhrzeit im Konsolenprotokoll
Ich habe folgende in meinem Start:
services.AddLogging(builder =>
{
builder.AddConfiguration(Configuration.GetSection("Logging"+Environment.EnvironmentName))
.AddConsole()
.AddDebug();
});
Appsettings.json:
"LoggingDevelopment": {
"IncludeScopes": false,
"Console": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
},
"LoggingProduction": {
"IncludeScopes": false,
"Console": {
"LogLevel": {
"Default": "Error",
"System": "Error",
"Microsoft": "Error"
}
}
},
Aktuelle [Entwicklung] log Layout (ohne Datum oder die Uhrzeit der Protokollzeile):
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action a.Controller (project) in 531.2457ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 532.5812ms 200 text/html; charset=utf-8
Im Produktionsmodus für Fehlerzeilen wäre ein Datum und eine Uhrzeit äußerst praktisch.
Diese könnte nützlich sein: https://github.com/aspnet/Logging/issues/483. –