2016-04-28 44 views
0

我剛將NancyFx Web應用程序中的NLog升級到版本4.3.2,並且該應用程序在第一次嘗試獲取Logger實例時現在會引發錯誤。被拋出的錯誤是:當一個獨立的EXENLog郵件目標在Web應用程序中使用時失敗

我已經收窄的問題倒在NLOG郵件的目標,這(根據其源)內不運行,必須指定

exePath嘗試讀取:

System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).GetSection( 「system.net/mailSettings/smtp」) 作爲SmtpSection

...嘗試從應用程序的web.config文件中查找郵件設置。 OpenExeConfiguration需要一個app.exe.config文件,該文件對於Web應用程序不存在。

所以,我的問題是如何告訴NLog在哪裏找到web.config文件,或者更好的是,我該如何告訴NLog不要打擾在web.config文件中查找,因爲我沒有存儲有沒有郵件設置?

這裏是我的目標XML在nlog.config:

<target xsi:type="Mail" 
     name="smtplog" 
     layout="${longdate} ${logger} ${message}" 
     useSystemNetMailSettings="false" 
     to="[email protected]" 
     from="[email protected]" 
     smtpUserName="USERNAME" 
     enableSsl="True" 
     smtpPassword="PASSWORD" 
     smtpAuthentication="Basic" 
     smtpServer="smtp.sendgrid.net" 
     smtpPort="587" /> 

如果我刪除的目標,然後應用程序加載的罰款。

ps的,這是工作得很好用NLOG的早期版本我使用(V2.1.0)

回答

0

這是NLOG 4.3.2中的錯誤,並已被固定在4.3.3

相關問題