Search code examples
c#asp.net-core-webapiasp.net-core-1.0rollbar

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


I'm using an asp.net core 1.0.1 web api project where Rollbar exception handling has implemented by using "RollbarDotNet": "0.5.1" version. It was working fine as I expected before but now there is no exception has captured.

I have followed the below article. https://github.com/RoushTech/RollbarDotNet but still the exception will not send it to Rollbar dashboard.

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%" ]
  }
}

I expect to send an exceptions to Rollbar dashboard with respective people via email notification.Rollbar Dashboard


Solution

  • You can use Rollbar official SDK for .NET, .NetCore, Xamarin, etc.

    It is available as a group of Nuget packages: