我的配置有问题EmailTraceListener
。我收到ActivationException
此消息的内部异常:
无法构造类型 TraceListener。您必须配置容器以提供此值。
这是我的 app.config 日志记录配置代码:
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add
name="Email Trace Listener"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fromAddress="fromAddress@gmail.com"
toAddress="toAddress@gmail.com"
smtpServer="smtp.gmail.com"
smtpPort="587"
authenticationMode="UserNameAndPassword"
useSSL="true"
userName="fromAddress"
password="password"
formatter="Text Formatter"/>
</listeners>
<formatters>
<add
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="{severity}{tab}{timestamp(local:dd/MM/yyyy [HH:mm:ss:FFFF] zzz)}{tab}{title}{tab}{message}{tab}
{dictionary([P]: {key}{tab}= {value}
)}"
name="Text Formatter" />
</formatters>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="FlatFile TraceListener"/>
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category"/>
<errors switchValue="All" name="Logging Errors & Warnings"/>
</specialSources>
</loggingConfiguration>
</configuration>
如果我用平面文件侦听器配置替换电子邮件侦听器配置 - 一切正常。电子邮件侦听器配置的错误在哪里?