Générer un fichier de log avec Entreprise Library 4.1
Je souhaite générer un fichier de log pour une application c# développée sous Visual Studio 2008.
Dans un premier temps, j'ai téléchargé le framework Entreprise Library 4.1. Ensuite, j'ai lancé EntLibConfig.exe ( répertoire C:\Program Files\Microsoft Enterprise Library 4.1 - October 2008\Bin).
Voici les instructions qui suivent extraites d'un tutoriel :
Select File > New Application;
Highlight the new application and select Action > New > Logging and Instrumentation Application Block;
Highlight the new application, then select File > Save Application;
Navigate to your project's directory;
Dans un second temps, j'ai écrit le code suivant afin de lancer un log de test :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.ObjectBuilder2;
namespace ConnectionSN
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
LogEntry log = new LogEntry();
log.EventId = 1;
log.Message = "--------------- Application is launched ------------ ";
log.Categories.Add("Trace");
} |
Problème le fichier de log Trace.log reste vide.
Je pense que j'ai dû mal configurer quelque chose, auriez-vous une idée!
Cordialement