J'utilise la fonction de journalisation par défaut en combinaison avec serilog pour écrire les informations de journalisation dans un fichier. Cela fonctionne, mais je n'arrive pas à trouver comment supprimer tous les messages d'information (principalement MVC). J'ai essayé un certain nombre d'options, ajouté Logging.Filter mais aucun résultat... J'utilise VS2015 et IIS-Express.
Logger output:
2016-06-16 19:34:52.984 +02:00 [Information] HttpContext.User merged via AutomaticAuthentication from authenticationScheme: "Identity.Application".
2016-06-16 19:34:52.993 +02:00 [Information] Executing action method "Test.Controllers.SurveysController.Create (Test)" with arguments (["Test.Survey"]) - ModelState is Invalid'
2016-06-16 19:34:53.027 +02:00 [Error] this is the error I want to show in "SurveysController"
System.DivideByZeroException: Attempted to divide by zero.
at Test.Controllers.SurveysController.<Create>d__7.MoveNext() in C:\Users\dummy\Documents\Visual Studio 2015\Projects\Test\src\Test\Controllers\SurveysController.cs:line 97
2016-06-16 19:34:53.061 +02:00 [Information] Executing ViewResult, running view at path "/Views/Surveys/Create.cshtml".
2016-06-16 19:34:53.083 +02:00 [Information] Executed action "Test.Controllers.SurveysController.Create (Test)" in 94.1372ms
2016-06-16 19:34:53.087 +02:00 [Information] Request finished in 111.506ms 200 text/html; charset=utf-8
Startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddSerilog();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug(LogLevel.Debug);
//extra package installed to try and filter logging
loggerFactory.WithFilter(new FilterLoggerSettings
{
{ "Microsoft", LogLevel.Warning },
{ "System", LogLevel.Warning },
{ "Test", LogLevel.Information }
});
appsettings.json:
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Error", // information => error
"System": "Error", // information => error
"Microsoft": "Error" // information => error
}