Giter Club home page Giter Club logo

bugsnag-net's Introduction

.NET Bugsnag

.NET Bugsnag is a notifier library for http://bugsnag.com. It includes support for logging Events, Exceptions, Stacktrace information, and meta information.

Build status

For more information about the examples below, you can visit https://bugsnag.com/docs/notifier-api for a full reference.

Quick Start

Install the NuGet package:

Install-Package Bugsnag.Library

Next, you will need to provide .NET BugSnag with your API key. There are 2 ways to do this: Choose one.

a) Add an AppSetting with your api key to your config (this is the easiest way)

<appSettings>
	<add key="BugSnagApiKey" value="[your api key here]" />
</appSettings>

b) In your application, call

BugSnag bs = new BugSnag()
{
    apiKey = "YOUR_API_KEY"
};

Use the library :)

Examples

Logging all errors in a web application

If you have a web application, this is the simplest way to add exception logging. In your global.asax, add the following to your application error handler (or create the handler if it doesn't already exist):

protected void Application_Error(object sender, EventArgs e)
{
    //  Create a new Bugsnag notifier
    BugSnag bs = new BugSnag();

    //  Notify.  This will get configuration from the web.config
    //  and gather all known errors and report them.  It's just that simple!
    bs.Notify();
}

Logging a single exception

Logging an exception in your application is also incredibly easy.

try
{
   // Some code that causes an exception
}
catch(SomeSpecificExceptionType ex)
{
   BugSnag bs = new BugSnag();
   bs.Notify(ex, null);
}

Including extra data

If you'd like to include extra data when you log exceptions, just pass it in the 'extra data' parameter. It can be a simple object with a few properties, or an incredibly complex set of meta data

try
{
   // Some code that causes an exception
}
catch(SomeSpecificExceptionType ex)
{

   BugSnag bs = new BugSnag();
   bs.Notify(ex, new
   {
       OtherReallyCoolData = new
       {
           color = "Yellow",
           mood = "Mellow"
       }
   });
}

It's just that simple!

bugsnag-net's People

Contributors

danesparza avatar staff0rd avatar staskar avatar

Watchers

 avatar  avatar  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.