问题描述
使用EnterpriseLibrary5Logging报错:“Microsoft.Practices.ServiceLocation.ActivationException”类型的未经处理的异常在Microsoft.Practices.ServiceLocation.dll中发生其他信息:ActivationerroroccuredwhiletryingtogetinstanceoftypeLogWriter,key""
我的配置及代码:<?xmlversion="1.0"encoding="utf-8"?><configuration><configSections><sectionname="loggingConfiguration"type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,Microsoft.Practices.EnterpriseLibrary.Logging,Version=5.0.414.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"requirePermission="true"/></configSections><loggingConfigurationname=""tracingEnabled="true"defaultCategory="General"><listeners><addname="EventLogTraceListener"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="EnterpriseLibraryLogging"formatter="TextFormatter"traceOutputOptions="LogicalOperationStack,DateTime,Timestamp,ProcessId,ThreadId,Callstack"/></listeners><formatters><addtype="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,Microsoft.Practices.EnterpriseLibrary.Logging,Version=5.0.414.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"template="Timestamp:{timestamp}{newline} Message:{message}{newline} Category:{category}{newline} Priority:{priority}{newline} EventId:{eventid}{newline} Severity:{severity}{newline} Title:{title}{newline} Machine:{localMachine}{newline} AppDomain:{localAppDomain}{newline} ProcessId:{localProcessId}{newline} ProcessName:{localProcessName}{newline} ThreadName:{threadName}{newline} Win32ThreadId:{win32ThreadId}{newline} ExtendedProperties:{dictionary({key}-{value}{newline})}"name="TextFormatter"/></formatters><categorySources><addswitchValue="All"name="General"><listeners><addname="EventLogTraceListener"/></listeners></add></categorySources><specialSources><allEventsswitchValue="All"name="AllEvents"><listeners><addname="EventLogTraceListener"/></listeners></allEvents><notProcessedswitchValue="All"name="UnprocessedCategory"><listeners><addname="EventLogTraceListener"/></listeners></notProcessed><errorsswitchValue="All"name="LoggingErrors&Warnings"><listeners><addname="EventLogTraceListener"/></listeners></errors></specialSources></loggingConfiguration><startup><supportedRuntimeversion="v4.0"sku=".NETFramework,Version=v4.6"/></startup></configuration>
staticvoidMain(string[]args){LogWriterlogWriter=EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();logWriter.Write("Test");Console.WriteLine("日志写入完成!");}