如何使用ASP.NET Core中的错误记录中间件将应用程序错误记录到数据库中?

问题描述

我想知道如何使用中间件在.net核心中实现数据库错误记录。 我在configure。的startup.cs中注入了app.UseLogging(env,applicationlifetime)。

    public static IApplicationBuilder UseLogging(this IApplicationBuilder app,IWebHostEnvironment env,IHostApplicationLifetime applicationLifetime)
    {
        // ACM.Core.Logging: This will close and flush the logging providers to dispatch all buffered messages to logging system.
        applicationLifetime.FlushLogging();

      if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            //app.UsebrowserLink();
        }
        else
        {
            // ACM.Core.Logging: Configure Logging middleware in non development mode
            app.UseLogging(new LoggingMiddlewareOptions
            {
                ErrorHandlingPath = "/Logging/Error",ApplicationType = ApplicationType.Professional
            });

            ACM.Core.Logging: Configure Logging middleware in non development mode
            app.UseExceptionHandling(new ExceptionHandlingOptions
            {
                ErrorHandlingPath = "/Logging/Error",ApplicationType = ApplicationType.Professional
            });
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)