Hangfire 错误`SQL 错误日志缺少连接字符串
Hangfire Error `Connection string is missing for the SQL error log
我正忙着尝试将 hangfire
添加到我的 MVC 项目中。我正在关注 Quick Start Guide
我已将其添加到我的 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 class 中的 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.
原来报错信息与hangfire无关。我只是在网络配置中没有用于 Elmah 的连接字符串。
我相信您当前的记录器是 Elmah,而 Hangfire 正在尝试获取 Elmah 日志记录以记录 Hangfire 作业的执行过程。如果你查看 Elmah 配置并检查你是否有类似 <logger name="*" minlevel="Trace" writeTo="network" />
的东西 - 这里你可以指定应用程序的 Elmah 记录器名称而不是 *,这样 Hangfire 就不能使用它。此解决方案是为了避免 Hangfire 记录到您的应用程序相关日志。
但是,如果您希望解决您面临的问题,请检查 ELmah 配置并查看是否正确设置了所需的连接字符串。
我正忙着尝试将 hangfire
添加到我的 MVC 项目中。我正在关注 Quick Start Guide
我已将其添加到我的 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 class 中的 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.
原来报错信息与hangfire无关。我只是在网络配置中没有用于 Elmah 的连接字符串。
我相信您当前的记录器是 Elmah,而 Hangfire 正在尝试获取 Elmah 日志记录以记录 Hangfire 作业的执行过程。如果你查看 Elmah 配置并检查你是否有类似 <logger name="*" minlevel="Trace" writeTo="network" />
的东西 - 这里你可以指定应用程序的 Elmah 记录器名称而不是 *,这样 Hangfire 就不能使用它。此解决方案是为了避免 Hangfire 记录到您的应用程序相关日志。
但是,如果您希望解决您面临的问题,请检查 ELmah 配置并查看是否正确设置了所需的连接字符串。