• Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 13 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby Logger that sends directly to a remote syslog endpoint

Remote Syslog Logger

This library providers an ActiveSupport compatible logger that logs directly to a remote syslogd via UDP.

Installation

The easiest way to install remote_syslog_logger is with Bundler. Add remote_syslog_logger to your Gemfile.

If you are not using a Gemfile, run:

$ [sudo] gem install remote_syslog_logger

Usage

Use from Rails:

config.logger = RemoteSyslogLogger.new('syslog.domain.com', 514,
                  :program => "rails-#{RAILS_ENV}",
                  :local_hostname => "optional_hostname")

With Rails 3+ if you want to use tagged logging wrap in a TaggedLogging instance:

config.logger = ActiveSupport::TaggedLogging.new(
                  RemoteSyslogLogger.new(
                    'syslog.domain.com', 514,
                    :program => "rails-#{RAILS_ENV}",
                    :local_hostname => "optional_hostname"
                  )
                )

Use from Ruby:

require 'remote_syslog_logger'
$logger = RemoteSyslogLogger.new('syslog.domain.com', 514)

To point the logs to your local system, use localhost and ensure that the system's syslog daemon is bound to 127.0.0.1.

Source

Remote Syslog Logger is available on GitHub, which can be browsed at:

http://github.com/papertrail/remote_syslog_logger

and cloned with:

$ git clone git://github.com/papertrail/remote_syslog_logger.git

Limitations

If the specified host cannot be resolved, syslog.domain.com in the example under the usage section above, remote_syslog_logger will block for approximately 20 seconds before displaying an error. This could result in the application failing to start or even stopping responding.

Workarounds for this include:

  • use an IP address instead of a hostname.
  • put a hosts entry in /etc/hosts or equivalent, so that DNS is not actually consulted
  • instead of logging directly to the network, write to a file and transmit new entries with a standalone daemon like remote_syslog,

Message length

All log lines are truncated to a maximum of 1024 characters. This restriction comes from RFC 3164 section 4.1:

The total length of the packet MUST be 1024 bytes or less.

Additionally, the generally-accepted MTU of the Internet is 1500 bytes, so regardless of the RFC, UDP syslog packets longer than 1500 bytes would not arrive. For details or to use TCP syslog for longer messages, see help.papertrailapp.com.

There is a max_size option to override this restriction, but it should only be used in extraordinary circumstances. Oversize messages are more likely to be fragmented and lost, with some receivers rejecting them entirely.

Default program name

By default, the program value is set to the name and ID of the invoking process. For example, puma[12345] or rack[3456].

The program value is used to populate the syslog "tag" field, must be 32 or fewer characters. In a few cases, an artifact of how the app is launched may lead to a default program value longer than 32 characters. For example, the thin Web server may generate a default program value such as:

thin server (0.0.0.0:3001)[11179]

If this occurs, the following exception will be raised when a RemoteSyslogLogger is instantiated:

Tag must not be longer than 32 characters (ArgumentError)

To remedy this, explicitly provide a program argument which is shorter than 32 characters. See Usage.

Contributing

Once you've made your great commits:

  1. Fork remote_syslog_logger
  2. Create a topic branch - git checkout -b my_branch
  3. Push to your branch - git push origin my_branch
  4. Create a Pull Request or an Issue with a link to your branch
  5. That's it!

You might want to checkout Resque's Contributing wiki page for information on coding standards, new features, etc.

License

Copyright (c) 2011-2016 Eric Lindvall. See LICENSE for details.

More Repositories

1

remote_syslog2

To install, see "Releases" tab. Self-contained daemon for reading local files and emitting remote syslog (without using local syslogd).
Go
637
star
2

papertrail-cli

Command-line client for Papertrail hosted syslog & app log management service
Ruby
427
star
3

legal-docs

Free, unencumbered NDA(s), employment agreement(s), and other legal contracts
311
star
4

remote_syslog

Deprecated in favor of https://github.com/papertrail/remote_syslog2
Ruby
220
star
5

go-tail

Go
71
star
6

logback-syslog4j

Logback appender for syslog4j
Java
49
star
7

papertrail-cookbook

Cookbook to setup logging to papertrailapp.com
Ruby
36
star
8

papertrail-heroku-plugin

Heroku command-line plugin to tail and search logs
JavaScript
31
star
9

slack-hooks

Relay webhooks to Slack webhooks
Clojure
21
star
10

dnsync

DNS Synchronization (from DNSimple to NSONE)
Ruby
18
star
11

rollout-zk

ZooKeeper adapter for Rollout
Ruby
17
star
12

profiler

Port of Twitter's Scala JVM-profiler to Java
Java
15
star
13

papertrail-hubot

Papertrail's plugins for hubot
CoffeeScript
10
star
14

chef-papertrail

Ruby
5
star
15

lotek

Experimental webhook for sending metrics from Papertrail to Librato Metrics
JavaScript
5
star
16

dnsync-heroku

Heroku Button for dnsync
Ruby
2
star
17

puppet-papertrail

Puppet
2
star
18

js-log-bridge-app

Tiny app to receive async HTTP requests contain logs, then output the payload (http://help.papertrailapp.com/kb/configuration/configuring-centralized-logging-from-javascript/)
Ruby
2
star
19

papertrail-cli-gem

Placeholder gem to redirect to new papertrail gem
Ruby
1
star
20

rails-2-preload

Optimizes testing with Spin and Rails 2
Ruby
1
star
21

salt-papertrail

SaltStack
1
star
22

ostrich-riemann

Twitter Ostrich adapter to send to Riemann
Scala
1
star