Giter Site home page Giter Site logo

nlog.airbrake's Introduction

Logo

NLog.AirBrake

An NLog target that sends exception information to AirBrake API compatible listeners This includes the hosted AirBrake service as well as Errbit, the open-source Ruby alternative.

If you have the means to do so, please give AirBrake your money and use their service!

We are using client code from SharpBrake to handle communication with AirBrake.

Installation

Use the Nuget package manager to install NLog.AirBrake

Configuration

You need to configure two things for this to work: NLog and AirBrake

NLog Configuration

Your NLog.config should look something like this:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <extensions>
    <!-- Add the assembly -->
    <add assembly="NLog.AirBrake" />
  </extensions>
  <targets>
    <!-- Set up the target -->
    <target xsi:type="AirBrake" name="airBrakeTarget" />
  </targets>
  <rules>
    <!-- Set up the logger. -->
    <logger name="*" minlevel="Trace" writeTo="airBrakeTarget" />
  </rules>
</nlog>

AirBrake Configuration

Your app.config file should look something like this:

<?xml version="1.0"?>
<configuration>
	<appSettings>
		<add key="Airbrake.ApiKey" value="[API_Key]" />
		<add key="Airbrake.Environment" value="[Environment]" />
		<add key="Airbrake.ServerUri" value="[ServerApiUri]" />
	</appSettings>
</configuration>

The values in the above that should be replaced are

  • [API_Key] - Self-explanatory
  • [Environment] - The name of the server environment in which the error occurred, such as 'staging' or 'production'.
  • [ServerApiUri] - The URI of the AirBrake API. For example:
    • http://api.airbrake.io/notifier_api/v2/notices (AirBrake)
    • http://yourservername/notifier_api/v2/notices (Self-hosted ErrBit)

Securing configuration information

Its recommended that whenever credentials are stored in config, that they be encrypted. That is beyond the scope of this README, but some information can be found here

Release Notes

0.6

  • Updated NLog versions from 2.0.0.2000 to 2.0.1.2

0.5

  • Added support for using target without exceptions

0.2 - .NET 3.5

  • Retargeted at .NET 3.5
  • Added missing NLog and NLog.config packages to nuspec as dependencies

0.1 - Initial release

  • It works!

Credits

  • Thanks to AirBrake for standardizing a simple error notifications API, that others could leverage.
  • Thanks to SharpBrake for making their code open source in a friendly MIT license that allows us to easily pull into our code. You guys are good open source citizens!
  • Thanks to NLog for the best open source logging framework for .NET
  • Thanks to Errbit for a great free piece of software to self-host for cheapskates ;0
  • The icon was derived from the published AirBrake and NLog logos - hopefully it falls under derivative works licensing.

Contributions

If you see something wrong, feel free to submit a pull request. Coding guidelines are :

  • Indent with 2 spaces
  • 80 character lines
  • Make sure the tests pass

nlog.airbrake's People

Contributors

bpruitt-goddard avatar donmcnamara avatar eastpoint-api avatar elindalyne avatar iristyle avatar linkexe avatar mroach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nlog.airbrake's Issues

compiler warnings in .net 4.0

When you reference the 2.0 version of this assembly in a 4.0 project, you get a compiler warning:

Warning 1 The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'd:\ScratchProjects\ConsoleApplication1\packages\NLog.AirBrake.0.4.1211.1918\lib\net40\NLog.AirBrake.dll' d:\ScratchProjects\ConsoleApplication1\CSC ConsoleApplication1

This is because of the empty ExtensionAttribute class used to make the extension methods work.

Even if we convert all the extension method calls to static method calls, the nlog assembly compiled against .net 2.0 has the same class defined. I think we may need to have 2 separate builds - one for 2.0 and one for 4.0.

Concatenate inner exception messages

We should recursively concatenate inner exception messages to get the full exception message to log, similar to the way that Exception.ToString() works.

Incorrect Line numbers

Airbrake is regularly reporting incorrect line numbers, requiring us to look elsewhere (e.g. DB logs) to find the actual log number if we wish to get any use from the service.

The line numbers in the other Nlog sources are always correct, so the issue seems to be somewhere between the error occuring and the Airbrake service.

Further investigation points towarks a possible issue with the current version of sharp brake which is in use - see airbrake/sharpbrake#29

AirBrake doesn't send Error()'s, only ErrorException()'s

Currently if you set a logger rule for "Error" as exampled below, and you use nLog.Error() instead of nLog.ErrorException(), Airbrake will not send an error report.

logger name="*" minlevel="Error" writeTo="airBrakeTarget"

Can we change this to allow either method to send the error?

Edit: Formatting

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.