Zapnologica
Zapnologica

Reputation: 22556

Hangfire Error `Connection string is missing for the SQL error log

I am busy trying to add hangfire to my MVC project. I am following the Quick Start Guide

I have added this to my startup.cs file

   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();
    }

However when I run my project I get the following error: (it highlights the GlobalConfiguration.Configuration.UseSqlServerStorage line in my startup.cs class)

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.

Upvotes: 0

Views: 1276

Answers (2)

Sujith
Sujith

Reputation: 1784

I believe you have your current logger as Elmah and Hangfire trying to pickup the Elmah logging to log the execution process of Hangfire jobs. If you look at the Elmah config and check if you have anything like <logger name="*" minlevel="Trace" writeTo="network" /> - here instead of * you can specify your application's Elmah logger name, so that Hangfire cannot use this. This solution is to avoid Hangfire logging to your application related log.

However if you wish to fix the issue you are facing, check the ELmah config and see if the required connection string is properly set.

Upvotes: 1

Zapnologica
Zapnologica

Reputation: 22556

It turns out the error message had nothing to do with hangfire. I simply did not have a connection string for Elmah in the web config.

Upvotes: 0

Related Questions