GithubHelp home page GithubHelp logo

longhairedsi / rollbarsharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mroach/rollbarsharp

0.0 1.0 0.0 173 KB

.NET bindings for the Rollbar.com error reporting service.

Home Page: https://www.nuget.org/packages/RollbarSharp/

License: Apache License 2.0

C# 99.87% ASP 0.13%

rollbarsharp's Introduction

RollbarSharp

Build status NuGet version Nuget downloads Coverage Status

.NET bindings for Rollbar.

I'm not affiliated with Rollbar, I just like their service.

Minimum version is .NET 4.5. There's also a dependency on System.Web.Routing, so you'll at least need ASP.NET MVC installed on the system.

Installation

RollbarSharp is available on Nuget and can be installed by:

PM> Install-Package RollbarSharp

Usage

Configuration

The easiest way to get going is to add the Rollbar.AccessToken item to your app settings.

<configuration>
  <appSettings>
    <add key="Rollbar.AccessToken" value="YOUR_TOKEN_HERE"/>
    <add key="Rollbar.Environment" value="production"/>
  </appSettings>
</configuration>

From there, you have several options on how to integrate with your app.

As an ASP.NET Filter

public class RollbarExceptionFilter : IExceptionFilter
{
    public void OnException(ExceptionContext filterContext)
    {
        if (filterContext.ExceptionHandled)
            return;

        (new RollbarClient()).SendException(filterContext.Exception);
    }
}

And then in Global.asax.cs you can do

GlobalFilters.Filters.Add(new RollbarExceptionFilter());

Or if you're using an inversion of control system that supports binding filters, you could do it there. This is an example with Ninject. You could even dependency-inject the RollbarClient if you want to create it in your own factory method.

kernel.BindFilter<RollbarExceptionFilter>(FilterScope.Global, 10).InSingletonScope();

The OnException method could instead be used verbatim inside a Controller if you add the override keyword. protected override void OnException(ExceptionContext filterContext) ...

As an ASP.NET application event handler (Global.asax.cs)

protected void Application_Error(object sender, EventArgs e)
{
    var exception = Server.GetLastError().GetBaseException();

    (new RollbarClient()).SendException(exception);
}

As an HttpModule in the Web.config

IIS Integrated Pipeline

<system.webServer>
    <modules>
        <add name="RollbarHttpModule" type="RollbarSharp.RollbarHttpModule"/>
    </modules>
</system.webServer>

IIS Classic Pipeline

<system.web>
    <httpModules>
        <add name="RollbarHttpModule" type="RollbarSharp.RollbarHttpModule"/>
    </httpModules>
</system.web>

As an NLog target

You'll need to add the NLog.RollbarSharp assembly to your project for this to work but it's available on NuGet. Check out the NLog.RollbarSharp README for configuration details, but here's the skinny:

<nlog>
    <extensions>
        <add assembly="NLog.RollbarSharp" />
    </extensions>
    <targets>
        <target xsi:type="RollbarSharp" name="rollbar" />
    </targets>
    <rules>
        <logger name="*" minlevel="Warn" writeTo="rollbar" />
    </rules>
</nlog>
<appSettings>
    <add key="Rollbar.AccessToken" value="6703358e9f54081e59bb0d65ee066363"/>
    <add key="Rollbar.Environment" value="development"/>
</appSettings>

Bugs

  • If you encounter a bug, performance issue, or malfunction, please add an Issue with steps on how to reproduce the problem.

Building

I'm using ScriptCs for managing the build process.

To build go to build folder and then run this command:

scriptcs -script build.csx

After that, upload new RollbarSharp.{version}.nupkg to nuget.

TODO

  • Add more tests

rollbarsharp's People

Contributors

mroach avatar albertomonteiro avatar richardversluis avatar webcoyote avatar bgurmendi avatar mm-pkohlhoff avatar atrejoe avatar uvcrew avatar mzochowski avatar sierzput avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.