locked
Problème de configuration Enterprise Library logging RRS feed

  • Question

  • Bonjour,

    voici ma configuration (  logging block )  mais j'ai une erreur d'instanciation

    App.config

     <configSections>
            <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
        </configSections>
        <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
            <listeners>
                <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                    source="Enterprise Library Logging" formatter="Text Formatter"
                    log="TraceLog" machineName="." traceOutputOptions="None" />
            </listeners>
            <formatters>
                <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                    template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
                    name="Text Formatter" />
            </formatters>
            <categorySources>
                <add switchValue="All" name="General">
                    <listeners>
                        <add name="Event Log Listener" />
                    </listeners>
                </add>
            </categorySources>
            <specialSources>
                <allEvents switchValue="All" name="All Events" />
                <notProcessed switchValue="All" name="Unprocessed Category" />
                <errors switchValue="All" name="Logging Errors &amp; Warnings">
                    <listeners>
                        <add name="Event Log Listener" />
                    </listeners>
                </errors>
            </specialSources>
        </loggingConfiguration>

    Et le code d'utilisation 

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Practices.EnterpriseLibrary.Logging;
    
    namespace AspectOriented.UnityInterceptors
    {
        public class LogTrace
        {
            /// <summary>
            /// 
            /// </summary>
            LogEntry logEntry = new LogEntry();
            /// <summary>
            /// 
            /// </summary>
            /// <param name="eventId"></param>
            /// <param name="priority"></param>
            /// <param name="message"></param>
            public LogTrace(int eventId, int priority, string message )
            {
                logEntry.EventId = eventId;// 100;
                logEntry.Priority = priority;// 2;
                logEntry.Message =  message;//"Informational message";
                Logger.Write(logEntry);
            }
        }
    }
    

    Mais j'ai l'erreur suivante a l’exécution :

    Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)".
    Exception occurred while: while resolving.
    Exception is: InvalidOperationException - The type LogWriter cannot be constructed. You must configure the container to supply this value.
    -----------------------------------------------
    At the time of the exception, the container was:


      Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,(none)

    dimanche 26 février 2012 19:37

Réponses