2013-07-23 37 views
0

我在EmailTraceListener的配置中遇到問題。我得到ActivationException,這個消息有一個內部例外:使用EmailTraceListener時Entlib日誌塊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="[email protected]" 
     toAddress="[email protected]" 
     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 &amp; Warnings"/> 
    </specialSources> 
    </loggingConfiguration> 
</configuration> 

如果我有一臺文件聽者配置取代電子郵件監聽器的配置 - 一切正常。 電子郵件偵聽程序配置中的錯誤在哪裏?

回答

1

問題是您的所有事件類別仍然連接到不再存在的FlatFile TraceListener。您的文件還有其他幾個可能應該解決的錯誤。我建議使用Configuration Console而不是手工編寫配置,或者至少在完成驗證後在配置控制檯中打開配置。

相關問題