使用 asp.net core 1.0.1 web api 应用程序未将错误消息发送到 Rollbar 仪表板

Error messages are not sending to Rollbar dashboard using asp.net core 1.0.1 web api application

我正在使用 asp.net 核心 1.0.1 web api 项目,其中 Rollbar 异常处理已通过使用 "RollbarDotNet": "0.5.1" 版本实现。它像我之前预期的那样工作正常,但现在没有捕获到异常。

我已关注以下文章。 https://github.com/RoushTech/RollbarDotNet 但异常仍然不会将其发送到 Rollbar 仪表板。

Startup.cs

    public class Startup
        {
            public Startup(IHostingEnvironment env)
            {
                var builder = new ConfigurationBuilder()
                    .SetBasePath(env.ContentRootPath)
                    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                    .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);         

                builder.AddEnvironmentVariables();
                Configuration = builder.Build();
            }
            public IConfigurationRoot Configuration { get; }

            public void ConfigureServices(IServiceCollection services)
            {  
                services.AddRollbar();
                services.Configure<RollbarOptions>(options => Configuration.GetSection("Rollbar").Bind(options));
            }
            public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
            {
                app.UseRollbarExceptionHandler();

                app.UseMvc();
            }
        }
    appsettings.dev.json:
    {
      "Rollbar": {
        "AccessToken": "xxxxxxxxxxxxxxxxxxxxxxxx",
        "Environment": "dev-idam"
      }
    }
Project.json
{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "RollbarDotNet": "0.5.1"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

我希望通过电子邮件通知向 Rollbar 仪表板发送例外情况。

您可以使用Rollbar official SDK for .NET, .NetCore, Xamarin, etc.

它作为一组 Nuget 包提供: