Giter Club home page Giter Club logo

gelf4nlog's Introduction

Gelf4NLog Build status Coverage Status

Gelf4NLog is an NLog target implementation to push log messages to GrayLog2. It implements the Gelf specification and communicates with GrayLog server via UDP.

Solution

Solution is comprised of 2 projects: Target is the actual NLog target implementation, and UnitTest contains the unit tests for the NLog target

Usage

Use Nuget:

PM> Install-Package Gelf4NLog.Target

Configuration

Here is a sample nlog configuration snippet:

<configSections>
  <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<extensions>
	  <add assembly="Gelf4NLog.Target"/>
	</extensions>

	<targets>
	  <!-- Other targets (e.g. console) -->
    
	  <target name="graylog" 
			  xsi:type="graylog" 
			  endpoint="udp://logs.local:12201" 
			  application="MyApp"
			  environment="PROD"
	  />
	</targets>

	<rules>
	  <logger name="*" minlevel="Debug" writeTo="graylog" />
	</rules>

</nlog>

Redacting sensitive log information

It is possible to redact sensitive information from each log entry using redaction regular expressions:

<targets>
	<target name="graylog" 
		xsi:type="graylog" 
		endpoint="udp://logs.local:12201" 
		application="MyApp" environment="PROD">
		<redact pattern="4[0-9]{12}(?:[0-9]{3})?" replacement="_REDACTED_" />
		<redact pattern="TEST" replacement="****" />
	</target>
</targets>

Options are the following:

  • name: arbitrary name given to the target
  • type: set this to "graylog"
  • endpoint: The address of the GrayLog2 server e.g. udp://logs.local:12201
  • application: The application
  • environment: The environment of the application instance

###Code

//excerpt from ConsoleRunner
var eventInfo = new LogEventInfo
    			{
					Message = comic.Title,
					Level = LogLevel.Info,
				};
eventInfo.Properties.Add("Publisher", comic.Publisher);
eventInfo.Properties.Add("ReleaseDate", comic.ReleaseDate);
Logger.Log(eventInfo);

##Contributing Would you be interested in contributing? All PRs are welcome.

gelf4nlog's People

Contributors

yesmarket avatar seymen avatar w4g3n3r avatar scottisaak avatar certegy avatar jburger avatar

Watchers

 avatar James Cloos avatar Jonathan Domian avatar Patrick Hartman avatar Dan Ramler avatar  avatar Kyle avatar Aimbase Build Server avatar  avatar Kanban Build Server avatar Jared Long avatar  avatar  avatar Huan Xu avatar  avatar Shawn Ferguson 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.