#199 Les logs des repository sont desormais disponibles sur la console et dans grafana pour faciliter le debuggage.

This commit is contained in:
josephine.vetu
2026-04-06 19:40:43 +02:00
parent 425ab13617
commit 9430c54b82
3 changed files with 5 additions and 11 deletions

View File

@@ -81,16 +81,8 @@ public class ArtisteController : Controller
Biographie = model.Biographie,
};
try
{
this.artisteRepository.Add(artiste);
this.logger.LogInformation("Création d'un nouvel artiste: {Nom}", artiste.Nom);
}
catch (Exception ex)
{
this.logger.LogError(ex, "Erreur lors de la création de l'artiste: {Nom}", artiste.Nom);
return this.View(model);
}
this.artisteRepository.Add(artiste);
this.logger.LogInformation("Création d'un nouvel artiste: {Nom}", artiste.Nom);
// Renvoyer sur la page Index.
return this.RedirectToAction("Index");

View File

@@ -2,7 +2,8 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Warning",
"Webzine.Repository": "Debug"
}
},
"Webzine": {

View File

@@ -29,6 +29,7 @@
<rules>
<!-- Vos logs d'application en Debug+ -->
<logger name="Webzine.WebApplication.*" minlevel="Info" writeTo="allfile,ownfile-web,console" />
<logger name="Webzine.Repository.*" minlevel="Debug" writeTo="allfile,ownfile-web,console" />
<!-- Logs Microsoft en Warning+ sauf Hosting.Lifetime -->
<logger name="Microsoft.*" minlevel="Warn" writeTo="allfile" final="true" />