2014-02-20 32 views
0

是否有可能建立企業庫只發送警告電子郵件對於某些類型的事件,其中「類型的事件」可以改變而無需重新編譯整個程序或不必編輯的一個.config文件?企業庫日誌和警報電子郵件

在一個完美的世界中,我可以切換SQL Server中的一個設置來說「默認情況下,通過電子郵件發送[email protected]。對於符合特定條件的源代碼,電子郵件b @示例.com,以及其他一些標準,請發送電子郵件至[email protected]「。

更一般地,我正在尋找一個日誌框架,這將讓我說「爲源1 2和3,垃圾郵件大家如果有什麼死但對於#4,只是電子郵件1人」。源是由應用處理的每一個文件的一些設置(雖然我打算做一些事情,讓1個線程1個電源正常所以這是一個選項太)。

我看到NLOG和log4net的也很受歡迎,但我沒有調查他們深深呢。

回答

0

您需要添加一個電子郵件監聽email trace listener。下面是從企業庫3.1

 <add toAddress="[email protected]" fromAddress="[email protected]" 
    subjectLineStarter="Load" subjectLineEnder="" smtpServer="mailserver.com" 
    smtpPort="25" formatter="Text Formatter" 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="Email TraceListener" /> 

然後,你需要添加specialsources

<specialSources> 
    <allEvents switchValue="All" name="All Events"> 
    <listeners> 
     <add name="Email TraceListener" /> 
    </listeners> 
    </allEvents> 
    <notProcessed switchValue="All" name="Unprocessed Category" /> 
    <errors switchValue="All" name="Logging Errors &amp; Warnings" /> 
</specialSources> 
一個示例
相關問題