0

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.
1
  • 1
    Perhaps the error message is misleading and it's just not a valid connection string. Often a connection string also has a provider in it. Just a guess Commented Jun 7, 2017 at 6:42

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

3 Comments

I think you have found solution by yourself.. great !!
Thanks for returning with a solution. It seems the hangfire doco must be incorrect when it says you can put a connection string in here directly. Do you mind posting both the final code and web.config that worked for you?
In case you have not seen this link : blog.elmah.io/elmah-tutorial It might help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.