问题描述
您好,
当我尝试使用以下功能编写日志时,收到以下错误消息。
I got the below error message when i tried to write log using below function.
public static void LogInformation(string title,string message,TraceEventType type,string category,string parameters)
{
LogEntry logEntry = new LogEntry();
LogEntry  log = new LogEntry();
logEntry.Title = title;
logEntry.Message = message;
logEntry.Severity = type;
logEntry.TimeStamp = DateTime.Now;
logEntry.Priority = 2;
logEntry.Categories.Add(category);
logEntry.ProcessName =" application";
logEntry.ExtendedProperties.Add(" Parameters",parameters);
// LogWriter lw = new LogWriterFactory(); ; // = EnterpriseLibraryContainer.Current.GetInstance< LogWriter>();
//lw.Write(logEntry);
Logger.Write(logEntry);
//Logger.Write(log);
// Logger.Write(logEntry.ToString());
}
public static void LogInformation(string title, string message, TraceEventType type, string category, string parameters)
{
LogEntry logEntry = new LogEntry();
LogEntry log = new LogEntry();
logEntry.Title = title;
logEntry.Message = message;
logEntry.Severity = type;
logEntry.TimeStamp = DateTime.Now;
logEntry.Priority = 2;
logEntry.Categories.Add(category);
logEntry.ProcessName = "application";
logEntry.ExtendedProperties.Add("Parameters", parameters);
//LogWriter lw = new LogWriterFactory(); ;// = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
//lw.Write(logEntry);
Logger.Write(logEntry);
//Logger.Write(log);
// Logger.Write(logEntry.ToString());
}
错误消息:
事件类型: 信息
活动来源: 例外情况
活动类别: 无
活动ID: 0
日期: 07 / 02/2012
时间: 15:09:51
用户: N / A
电脑: evw3300536.GBR.lebara
描述:
Microsoft.Practices.Unity.ResolutionFailedException:依赖项的解析失败,type =" Microsoft.Practices.EnterpriseLibrary.Logging .LogWriter",name ="(none)"。$
在解析时发生异常。
异常是:InvalidOperationException - 无法构造数据库类型。您必须配置容器以提供此值。
-------------------------------- ---------------
在例外情况下,容器是:
Event Type: Information
Event Source: Exception
Event Category: None
Event ID: 0
Date: 07/02/2012
Time: 15:09:51
User: N/A
Computer: evw3300536.GBR.lebara
Description:
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:
解决Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter .__ default __(从Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter映射,(无))
解析参数"structureHolder"构造函数Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder structureHolder,Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider
instrumentationProvider,Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator updateCoordinator )
解决Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder .__ default__(从Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder映射,(无))
&NBSP;&NBSP;&NBSP;解析参数"traceSources"构造函数Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable`1 [[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter,Microsoft.Practices.EnterpriseLibrary.Logging,
Version = 5.0] .414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35]] filters,System.Collections.Generic.IEnumerable`1 [[System.String,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]] traceSourceNames,System。 Collections.Generic.IEnumerable`1 [Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,
Microsoft.Practices.EnterpriseLibrary.Logging,版本= 5.0.414.0,文化=中性公钥= 31bf3856ad364e35]] traceSources,微软。 Practices.EnterpriseLibrary.Logging.LogSource allEventsTraceSource,Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
notProcessedTraceSource,Microsoft.Practices.EnterpriseLibrary.Logging.LogSource errorsTraceSource,System.String defaultCategory,System.Boolean tracingEnabled,System.Boolean logWarningsWhenNoCategoriesMatch,System.Boolean revertImpersonation)
解决Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,General
解析参数"traceListeners"构造函数Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String name,System.Collections.Generic.IEnumerable`1 [[System.Diagnostics.TraceListener,System,Version = 2.0.0.0,
Culture = neutral, PublicKeyToken = b77a5c561934e089]] traceListeners,System.Diagnostics.SourceLevels level,System.Boolean autoFlush,Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider)
&NBSP;&NBSP;解析Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper,DBListener(从System.Diagnostics.TraceListener,DBListener映射)
解析参数"wrappedTraceListener"构造函数Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(System.Diagnostics.TraceListener wrappedTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator
coordinator)
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;解决Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener,DBListenerimplementation
&NBSP(从System.Diagnostics.TraceListener,DBListenerimplementation映射);&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;解析参数"数据库"构造函数Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener(Microsoft.Practices.EnterpriseLibrary.Data.Database数据库,System.String
writeLogStoredProcName,System.String addCategoryStoredProcName,Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter格式化程序)
解析Microsoft.Practices.EnterpriseLibrary.Data.Database,LoggingDB
---> System.InvalidOperationException:无法构造数据库类型。您必须配置容器才能提供此值。
在Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext context,SelectedConstructor selectedConstructor)
在Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext context,NamedTypeBuildKey buildKey)
在Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
在Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
在BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener(IBuilderContext)
在Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
在Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
在BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(IBuilderContext)
在Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
在Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
在Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.DoResolve [T](IBuilderContext context,IDependencyResolverPolicy [] elementPolicies)
在BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(IBuilderContext)
在Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
在Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
在Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.DoResolve [T](IBuilderContext context,IDependencyResolverPolicy [] elementPolicies)
在BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(IBuilderContext)
在Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
在Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
在BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(IBuilderContext)
在Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
在Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
在Microsoft.Practices.Unity.UnityContainer.DoBuildUp(类型t,对象存在,字符串名称,IEnumerable`1 resolverOverrides)
---内部异常堆栈跟踪结束---
在Microsoft.Practices.Unity.UnityContainer.DoBuildUp(类型t,对象存在,字符串名称,IEnumerable`1 resolverOverrides)
在Microsoft.Practices.Unity.UnityContainer.Resolve(Type t,String name,ResolverOverride [] resolverOverrides)
在Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(输入serviceType,String key)
在Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(类型serviceType,String key)
Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.__default__ (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, (none))
Resolving parameter "structureHolder" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder structureHolder, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator updateCoordinator)
Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.__default__ (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder, (none))
Resolving parameter "traceSources" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] filters, System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceSourceNames, System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] traceSources, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource allEventsTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource notProcessedTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource errorsTraceSource, System.String defaultCategory, System.Boolean tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch, System.Boolean revertImpersonation)
Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,General
Resolving parameter "traceListeners" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String name, System.Collections.Generic.IEnumerable`1[[System.Diagnostics.TraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceListeners, System.Diagnostics.SourceLevels level, System.Boolean autoFlush, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider)
Resolving Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper,DBListener (mapped from System.Diagnostics.TraceListener, DBListener)
Resolving parameter "wrappedTraceListener" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(System.Diagnostics.TraceListener wrappedTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator coordinator)
Resolving Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener,DBListenerimplementation (mapped from System.Diagnostics.TraceListener, DBListenerimplementation)
Resolving parameter "database" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener(Microsoft.Practices.EnterpriseLibrary.Data.Database database, System.String writeLogStoredProcName, System.String addCategoryStoredProcName, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter)
Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,LoggingDB
---> System.InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value.
at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext context, SelectedConstructor selectedConstructor)
at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext context, NamedTypeBuildKey buildKey)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
at BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
at BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
at Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.DoResolve[T](IBuilderContext context, IDependencyResolverPolicy[] elementPolicies)
at BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
at Microsoft.Practices.Unity.ResolvedArrayWithElementsResolverPolicy.DoResolve[T](IBuilderContext context, IDependencyResolverPolicy[] elementPolicies)
at BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
at BuildUp_Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
--- End of inner exception stack trace ---
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
有关详细信息,请参阅
http://go.microsoft.com/fwlink/events.asp 。
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
App.Config文件:
App.Config File:
<?xml version =" 1.0"编码= QUOT; UTF-8英寸?>
$
< configuration>
< configSections>
< section name =" loggingConfiguration"类型= QUOT; Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,Microsoft.Practices.EnterpriseLibrary.Logging,版本= 3.1.0.0,文化=中性公钥= b03f5f7f11d50a3a" />
&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP; < section name =" dataConfiguration" type =" Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.Practices.EnterpriseLibrary.Data,Version = 3.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a" />
  ;&NBSP;&NBSP; < / configSections>
< loggingConfiguration name =" Logging Application Block" tracingEnabled = QUOT;真" defaultCategory = QUOT;通用及QUOT; logWarningsWhenNoCategoriesMatch =" true">
< listeners>
< add databaseInstanceName =" LoggingDB" writeLogStoredProcName = QUOT; WRITELOG" addCategoryStoredProcName = QUOT; AddCategory"格式化= QUOT; TFormatter" listenerDataType =" Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging.Database,Version = 3.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a" traceOutputOptions = QUOT;无"类型= QUOT; Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging.Database,
版= 3.1.0.0,文化=中性公钥= b03f5f7f11d50a3a" name =" DBListener" />
<! - SFA ESB App配置 - >
< add toAddress =" " fromAddress =" " subjectLineStarter =" SFA HeartBeat" subjectLineEnder = QUOT;" SMTPSERVER = QUOT; smtp.test.com"
smtpPort =" 25"格式化= QUOT; TFormatter" listenerDataType =" Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData,Microsoft.Practices.EnterpriseLibrary.Logging,Version = 3.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a" traceOutputOptions = QUOT;无"
type =" Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging,Version = 3.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a" name =" EmailListener" />
< / listeners>
< formatters>
< add template ="时间戳:{timestamp}& #xA;消息:{message}& #xA;类别:{category}& #xA;优先级:{priority}& #xA; EventId:{ eventid}& #xA;严重性:{严重}& #xA;标题:{title}& #xA;计算机:{machine}& #xA;应用
域名:{appDomain}&# xA;进程ID:{processId}& #xA;进程名称:{processName}& #xA; Win32线程ID:{win32ThreadId}& #xA;线程名称:{threadName}& #xA;扩展属性: {dictionary({key} - {value}& #xA;)}" type =" Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,
Microsoft.Practices.EnterpriseLibrary.Logging,Version = 3.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a" name =" TFormatter" />
< / formatters>
< categorySources>
< add switchValue =" All" name =" General">
< listeners>
< add name =" DBListener" />
< add name =" EmailListener" />
< / listeners>
< / add>
< add switchValue =" All" name =" Critical">
< listeners>
< add name =" DBListener" />
< add name =" EmailListener" />
< / listeners>
< / add>
< add switchValue =" All" name =" DBExceptions">
< listeners>
< add name =" DBListener" />
< add name =" EmailListener" />
< / listeners>
< / add>
< add switchValue =" All" name =" UnhandledException">
< listeners>
< add name =" DBListener" />
< add name =" EmailListener" />
< / listeners>
< / add>
< add switchValue =" All" name =" Information">
< listeners>
< add name =" DBListener" />
< add name =" EmailListener" />
< / listeners>
< / add>
< add switchValue =" All" name =" Audit">
< listeners>
< add name =" DBListener" />
< / listeners>
< / add>
< / categorySources>
< specialSources>
< allEvents switchValue =" All" name =" All Events" /
< notProcessed switchValue =" All" name =" Unprocessed Category" />
< errors switchValue =" All" name =" Logging Errors& amp;警告"/>
< / specialSources>
< / loggingConfiguration>
< connectionStrings>
< add name =" LoggingDB" connectionString =" Data Source = 192.168.0.153; Initial Catalog = Logging; User ID = Test; Password = Test" providerName =" System.Data.SqlClient" />
< / connectionStrings>
< system.serviceModel>
< bindings>
< basicHttpBinding>
< binding name =" BasicHttpBinding_ITwoWayAsync" closeTimeout =" 00:05:00"
openTimeout = QUOT; 00:05:00" receiveTimeout = QUOT; 00:05:00" sendTimeout =" 00:05:00"
allowCookies = QUOT假QUOT; bypassProxyOnLocal = QUOT假QUOT; hostNameComparisonMode =" StrongWildcard"
MAXBUFFERSIZE = QUOT; 65536" maxBufferPoolSize = QUOT; 524288" maxReceivedMessageSize =" 65536"
messageEncoding = QUOT;文本" textEncoding = QUOT; UTF-8英寸transferMode =" Buffered"
useDefaultWebProxy =" true">
< readerQuotas maxDepth =" 32" maxStringContentLength = QUOT; 8192" maxArrayLength =" 16384"
maxBytesPerRead = QUOT; 4096" maxNameTableCharCount = QUOT; 16384" />
$
< security mode =" None">
< transport clientCredentialType =" None" proxyCredentialType =" None"
realm ="">
< extendedProtectionPolicy policyEnforcement =" Never" />
$
< / transport>
< message clientCredentialType =" UserName" algorithmSuite = QUOT;默认" />
$
< / security>
< / binding>
< / basicHttpBinding>
< / bindings>
< client>
< endpoint address =" "
结合= QUOT; basicHttpBinding的" bindingConfiguration =" BasicHttpBinding_ITwoWayAsync"
合同= QUOT; SFAService.SFAService"名称= QUOT; BasicHttpBinding_ITwoWayAsync" />
$
< / client>
< /system.serviceModel>
< / configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add databaseInstanceName="LoggingDB" writeLogStoredProcName="WriteLog" addCategoryStoredProcName="AddCategory" formatter="TFormatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="DBListener"/>
<!-- SFA ESB App Configurations -->
<add toAddress="[email protected]" fromAddress="[email protected]" subjectLineStarter="SFA HeartBeat " subjectLineEnder="" smtpServer="smtp.test.com" smtpPort="25" formatter="TFormatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="EmailListener"/>
</listeners>
<formatters>
<add template="Timestamp: {timestamp}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
Extended Properties: {dictionary({key} - {value}
)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="TFormatter"/>
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="DBListener"/>
<add name="EmailListener"/>
</listeners>
</add>
<add switchValue="All" name="Critical">
<listeners>
<add name="DBListener"/>
<add name="EmailListener"/>
</listeners>
</add>
<add switchValue="All" name="DBExceptions">
<listeners>
<add name="DBListener"/>
<add name="EmailListener"/>
</listeners>
</add>
<add switchValue="All" name="UnhandledException">
<listeners>
<add name="DBListener"/>
<add name="EmailListener"/>
</listeners>
</add>
<add switchValue="All" name="Information">
<listeners>
<add name="DBListener"/>
<add name="EmailListener"/>
</listeners>
</add>
<add switchValue="All" name="Audit">
<listeners>
<add name="DBListener"/>
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events"/>
<notProcessed switchValue="All" name="Unprocessed Category"/>
<errors switchValue="All" name="Logging Errors & Warnings"/>
</specialSources>
</loggingConfiguration>
<connectionStrings>
<add name="LoggingDB" connectionString="Data Source=192.168.0.153;Initial Catalog=Logging;User ID=Test;Password=Test" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITwoWayAsync" closeTimeout="00:05:00"
openTimeout="00:05:00" receiveTimeout="00:05:00" sendTimeout="00:05:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://evw3300536.gbr.Test/EsbSfaService/SFAService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITwoWayAsync"
contract="SFAService.SFAService" name="BasicHttpBinding_ITwoWayAsync" />
</client>
</system.serviceModel>
</configuration>
谢谢,
Krunal
推荐答案
请查看:   ;
Please have a look at: http://entlib.codeplex.com/discussions/215290
我希望它有所帮助!
这篇关于Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter Writelog错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!