0

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

我遵循了下面的文章。 https://github.com/RoushTech/RollbarDotNet但异常仍然不会将其发送到 Rollbar 仪表板。

启动.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 仪表板发送例外情况。防滚杆仪表板

4