Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
/ NLog.Raygun Public archive
forked from MindscapeHQ/NLog.Raygun

A custom NLog target that will push errors to Raygun

License

Notifications You must be signed in to change notification settings

Quadrotech/NLog.Raygun

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NLog.Raygun

A custom NLog target that will push exceptions to Raygun.

Configuration

You need to configure NLog.config.

Settings

  • ApiKey - your API key
  • Tags - tags you want to send in with every exception
  • IgnoreFormFieldNames - form fields you wish to ignore, eg passwords and credit cards
  • IgnoreCookieNames - cookies you wish to ignore, eg user tokens
  • IgnoreServerVariableNames - Server vars you wish to ignore, eg sessions
  • IgnoreHeaderNames - HTTP header to ignore, eg API keys
  • UseIdentityNameAsUserId - If you're using a web project, send user name from HttpContext.Current.User.Identity.Name? Used for User Tracking

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.Raygun"/>
  </extensions>
  <targets>
    <!-- Set up the target -->
    <target name="asyncRaygun" xsi:type="AsyncWrapper">
		  <target 
        name="RayGunTarget" 
        type="RayGun" 
        ApiKey="" 
        Tags="" 
        IgnoreFormFieldNames="" 
        IgnoreCookieNames=""
				IgnoreServerVariableNames="" 
        IgnoreHeaderNames=""
        UseIdentityNameAsUserId="true"
				layout="${uppercase:${level}} ${message} ${exception:format=ToString,StackTrace}${newline}"
      />
	 </target>
  </targets>
  <rules>
    <!-- Set up the logger. -->
    <logger name="*" minlevel="Error" writeTo="RayGunTarget" />
  </rules>
</nlog>

Tags

You can add tags per exception by putting a List of tags into your Exception.Data array using the Tags key

var e = new Exception("Test Exception");
e.Data["Tags"] = new List<string> { "Tester123" }; 

About

A custom NLog target that will push errors to Raygun

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 78.5%
  • JavaScript 16.5%
  • HTML 4.4%
  • Other 0.6%