2017-06-07 49 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