0.0
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Simple file based logging for Logstash.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Logstash File Logger

Logstash

The logstash-file Gem is yet another Logstash logger but instead of using a network transporation layer such as TCP or UDP it writes JSON data to a file.

The LogstashFile::Logger class provides a Logger-like interface by supplying methods such as info, error, etc. Unlike the Logger API they take a 2nd optional argument that can be used to specify custom fields to set in the logging message. See below for more information.

Requirements

  • Ruby 1.9.3 or newer

Supported Rubies

  • Ruby 1.9.3
  • Ruby 2.x
  • Jruby 1.7 and newer
  • Rubinius 2.0 and newer, 2.1 or newer is recommended

Tests are ran on both Travis CI as well as the private Jenkins instance of Olery. Although this Gem may work on Ruby 1.8 we have not verified this nor do we intend to.

Usage

First install the Gem:

gem install logstash-file

Basic logging is as following:

require 'logstash-file'

logger = LogstashFile::Logger.new(STDOUT)

logger.info("Hello!") # => {"@fields": {"level": "info"}, "@message": "Hello!", "@timestamp": "..."}

# Logging using custom fields
logger.info("Hello!", :user => "Alice") # => {"@fields": {"user": "Alice", ...}, ...}

License

The source code of this repository and logstash-file itself are licensed under the MIT license unless specified otherwise. A copy of this license can be found in the file "LICENSE" in the root directory of this repository.