Giter VIP home page Giter VIP logo

yell-adapters-gelf's Introduction

Yell Gelf - Graylog2 Adapter for Your Extensible Logging Library

If you are not yet familiar with Yell - Your Extensible Logging Library check out the githup project under https://github.com/rudionrails/yell or jump directly into the Yell wiki at https://github.com/rudionrails/yell/wiki.

Just in case you wonder: GELF means Graylog Extended Log Format. Read all it at http://www.graylog2.org/about/gelf.

Build Status

The Graylog adapter for Yell works and is tested with ruby 1.8.7, 1.9.x, jruby 1.8 and 1.9 mode, rubinius 1.8 and 1.9 as well as ree.

Installation

System wide:

gem install yell-adapters-gelf

Or in your Gemfile:

gem "yell-adapters-gelf"

Usage

After you set-up Graylog2 accordingly, you may use the Gelf adapter just like any other.

logger = Yell.new :gelf

# or alternatively with the block syntax
logger = Yell.new do |l|
  l.adapter :gelf
end

logger.info 'Hello World!'

Now check your Graylog2 web server for the received message. By default, the gelf adapter will send the following information to Graylog2:

facility: The GELF facility (default: 'yell')
level: The current log level
timestamp: The time when the log event occured
host: The current hostname
file: The name of the file where the log event occured
line: The line in the file where the log event occured
_method: The method where the log event occured
_pid: The PID of your current process

Example: Running with a different GELF facility

logger = Yell.new :gelf, :facility => 'my own facility'

# or with the block syntax
logger = Yell.new do |l|
  l.adapter :gelf, :facility => 'my own facility'
end

Example: Running Graylog2 on a different host or port

logger = Yell.new :gelf, :host => '127.0.0.1', :port => 1234

# or with the block syntax
logger = Yell.new do |l|
  l.adapter :gelf, :host => '127.0.0.1', :port => 1234
end

logger.info 'Hello World!'

Example: Passing additional keys to the adapter

logger = Yell.new :gelf

logger.info "Hello World", "_thread_id" => Thread.current.object_id, 
                           "_current_user_id" => current_user.id

Copyright © 2012 Rudolf Schmidt, released under the MIT license

yell-adapters-gelf's People

Contributors

formigarafa avatar rudionrails avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

yell-adapters-gelf's Issues

Make it possible to use global additional gelf parameter

Hi Rudi,

as discussed here: rudionrails/yell#24 (comment) I wanted to add a feature request for the yell-adapters-gelf.

It would be great if one could add a global additional gelf parameter/ field so that every message send to the server would also carry the additional field without explicitly add it to every message directly.

For example additional field "logger_name" submitted for every message:

logger.adapter :gelf, :host => '192.168.65.144',
                              :port => 12201,
                              :facility => DAEMON_NAME + curr_env,
                              "_logger_name" => name

Don't know if such a thing is even possible but I would find this very much useful!

best
Martin

List on Graylog Marketplace

We have launched the beta of the Graylog Marketplace: https://marketplace.graylog.org/

The Marketplace is the central directory of all Graylog add-ons and integrations, including GELF libraries.

You would help us a lot if you could submit your GELF library there as we will be shutting down the old listing of GELF libraries soon.

Support for custom fields

How about adding support for custom fields?

Perhaps something like this in greylog.rb :
_datagrams = datagrams(
{'version' => '1.0',
...
...
}.merge(Thread.current["custom_log_fields"] || {})
)

Allow to set UDP or TCP protocoll

Since GELF protocoll supports TCP as well as TCP it would be good if one could set the protocol also within yell-adapters-gelf. Currently it is sending via UDP as a default.

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.