2017-06-07 50 views
0

我正在忙着嘗試將hangfire添加到我的MVC項目中。我下面的Quick Start GuideHangfire錯誤連接字符串缺少SQL錯誤日誌

我已經加入這個我startup.cs文件

public void Configuration(IAppBuilder app) 
    { 
     ConfigureAuth(app);   

     //Hangfire 
     GlobalConfiguration.Configuration.UseSqlServerStorage("data source=ip;initial catalog=Name;user id=Hangfire;password=Password;"); 
     app.UseHangfireDashboard(); 
     app.UseHangfireServer(); 
    } 

然而,當我跑我的項目,我得到以下錯誤:(它突出在我startup.cs類GlobalConfiguration.Configuration.UseSqlServerStorage線)

Connection string is missing for the SQL error log. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: Elmah.ApplicationException: Connection string is missing for the SQL error log. 
+1

也許錯誤消息是誤導性的,它只是不是一個有效的連接字符串。連接字符串通常也有一個提供者。只是猜測 –

回答

1

我相信你有你當前的記錄器作爲Elmah和Hangfire試圖拾取Elmah日誌來記錄Hangfire作業的執行過程。如果你看看Elmah的配置,並檢查你是否有類似<logger name="*" minlevel="Trace" writeTo="network" />的東西 - 在這裏而不是*,你可以指定你的應用程序的Elmah記錄器名稱,以便Hangfire不能使用它。此解決方案是爲了避免Hangfire記錄到您的應用程序相關日誌。

但是,如果您希望解決您面臨的問題,請檢查ELmah配置並查看是否正確設置了所需的連接字符串。

0

事實證明,這個錯誤信息與hangfire無關。我只是在Web配置中沒有Elmah的連接字符串。

+0

我認爲你已經找到了自己的解決方案..太棒了! – Sujith

+0

感謝您使用解決方案返回。看來doco一定是不正確的,因爲它說你可以直接在這裏放置一個連接字符串。你介意發佈最終的代碼和web.config爲你工作嗎? –

+0

如果你還沒有看到這個鏈接:https://blog.elmah.io/elmah-tutorial/它可能會幫助你。 – Sujith