Code Monkey home page Code Monkey logo

gelf4net's Introduction

watters/gelf4net

Overview

This fork introduces a handful of breaking changes from the original gelf4net, including:

  • separate appenders for UDP and AMQP
  • simplified class structure
  • disallows UDP messages with more than 128 chunks (per GELF spec)
  • always sends file/line number if it's in the loggingEvent
  • renamed a couple of configuration properties

(NOTE: I've done less work on AMQP since I don't use it, but I'd expect it to work)

Usage

Properties

All Appenders

  • string AdditionalFields //Key:Value CSV ex: app:MyApp,version:1.0
  • string Facility
  • string Host
  • string RemoteAddress
  • int RemotePort

UDF Appender

  • int ChunkSize

AMQP Appender

  • int GrayLogServerAmqpPort
  • string GrayLogServerAmqpUser
  • string GrayLogServerAmqpPassword
  • string GrayLogServerAmqpVirtualHost
  • string GrayLogServerAmqpQueue

Per-message custom fields

Any properties returned from LoggingEvent.GetProperties() will be appended as custom properties. This includes properties set on GlobalContext and ThreadContext (see: http://logging.apache.org/log4net/release/manual/contexts.html).

Additionally, the appender will reflect over the LoggingEvent.MessageObject looking for properties of a type that implements IDictionary. It will then include all of these values as well. If name collisions are detected, the appender will prefer the most-specific values:

  1. Fields retrieved from MessageObject
  2. Fields retrieved from LoggingEvent.GetProperties()
  3. Fields specified in the appender configuration

The core GELF field "short_message" can be specified per-message by adding a string property to your custom message object (LoggingEvent.MessageObject) named "short_message" or "ShortMessage".

log4net Xml Configuration

<?xml version="1.0"?>
<configuration>
	<configSections>
		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
	</configSections>

	<log4net>
		<root>
			<level value="DEBUG"/>
			<appender-ref ref="UdpGelfAppender"/>
		</root>

		<appender name="UdpGelfAppender" type="Esilog.Gelf4net.UdpGelfAppender, Esilog.Gelf4net">
			<param name="RemoteAddress" value="public-graylog2.taulia.com" />
			<param name="Facility" value="RandomPhrases" />
			<param name="AdditionalFields" value="app:RandomSentence,version:1.0" />

			<layout type="log4net.Layout.PatternLayout">
				<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss}%m%n"/>
			</layout>
		</appender>
	</log4net>

	<startup>
		<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
	</startup>
</configuration>

Copyright and License

watters/gelf4net

forked from: jjchiw/gelf4net created by Juan J. Chiw - Copyright 2011

based on: gelf4j created by Philip Stehlik - Copyright 2011

See LICENSE for license details

gelf4net's People

Contributors

jjchiw avatar pstehlik avatar russpall avatar crowleym avatar

Watchers

Jeremy Einfeld 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.