papertrail / remote_syslog_logger Goto Github PK
View Code? Open in Web Editor NEWRuby Logger that sends directly to a remote syslog endpoint
License: MIT License
Ruby Logger that sends directly to a remote syslog endpoint
License: MIT License
Would it be interest in support this plugin for IPv6? My servers are IPv6 only.
http://help.papertrailapp.com/discussions/problems/72-log-lines-truncated-after-962-characters.html
This renders long log lines pretty useless, as you might lose some crucial data and it can't be recovered.
Our site is having problems at the moment resolving logs.papertrailapp.com. This results in the following message being printed when trying to write to the logger:
RemoteSyslogLogger::UdpSender error: SocketError: getaddrinfo: Temporary failure in name resolution
The problem is that this only happens after 20s (system/Ruby socket timeout?) essentially bringing our entire app down.
Before I start implementing anything: what do you think about adding a 100ms (or less) timeout around sending logs?
I found that Rails.logger.silence
blocks fail when using this gem. The issues seems to be that RemoteSyslogLogger.new
instantiates aLogger
, when it should be instantiating an ActiveSupport::Logger
. Reference: https://stackoverflow.com/a/38361137
In production.rb I have...
config.logger = ActiveSupport::TaggedLogging.new(...)
config.colorize_logging = false
config.log_level = :info
But then, I start seeing SQL statements in the logs. Adding the following will cause nil errors:
config.active_record.logger = nil
What's the recommended way to stop activerecord from outputing sql statements?
This is for a Rails legacy site running v3.2.X.
Thanks in advance.
Could you add support for TCP protocol in remote_syslog_logger ?
When my sinatra app tries to send a message to Papertrail using remote_syslog_logger from Heroku I get the following error:
!! Unexpected error while processing request: can't dump UDPSocket
I am running Rails4 application where I am using the remote_syslog_logger gem to do logging on Remote machine, in the same time I want to do logging in the applciation machine(Machine where my application is running). Is it possible with this gem?
RFC 5424 says that the hostname should be fully-qualified. The default hostname is currently determined using Socket.gethostname
, which returns the unqualified hostname. It should use something like this instead to determine the FQDN.
Is there anyway this could support sending overt the TCP Protocol (instead of UDP)? I want to take advantage of the larger message size.
The README incorrectly declares that UDP messages >1500 bytes (eg, the most common MTU) cannot be transmitted. UDP packets of arbitrary length can be transmitted via IP fragmentation. The caveat being that if any one of the fragments is not received, the entire datagram cannot be reassembled and the message is lost.
Given this, I think there should be a config option to not truncate messages (with clear warnings that this is not RFC-compliant and the larger the message, the greater the chance of it being lost in transit).
EDIT: After looking through the code, the truncation is done in the syslog_protocol
gem and therefore isn't relevant here. However it would be nice to have an option to not split the message by lines.
Rails 3+ supports adding per-request tags to log entries (particularly useful for logging requests' uuid). RSL just ignores them, it seems.
How do we feel about allowing instantiation with a connection string?
I find myself instantiating a RemoteSyslogLogger
by using several lines of code, instead of something simpler - like:
logger = RemoteSyslogLogger.new "syslog://system:[email protected]:514"
This will not only make things shorter and easier, but will have the added bonus of allowing to simply use an environment variable as the connection string, like we do with redis, database and others.
logger = RemoteSyslogLogger.new ENV['SYSLOG_URL']
Here is my monkey patch proof of concept:
require 'remote_syslog_logger'
require 'uri'
module RemoteSyslogLogger
class << self
alias_method :original_new, :new
def new(*args)
args = ['syslog://localhost:514'] if args.empty?
if args.count == 1 and args.first.is_a? String
uri = URI args.first
original_new uri.host, uri.port, local_hostname: uri.user, program: uri.password
else
original_new *args
end
end
end
end
logger0 = RemoteSyslogLogger.new '127.0.0.1', '514', local_hostname: 'myhost', program: 'myprog'
logger1 = RemoteSyslogLogger.new "syslog://system:[email protected]:514"
logger2 = RemoteSyslogLogger.new "syslog://127.0.0.1:514"
logger3 = RemoteSyslogLogger.new
logger0.info "Tadaaa 0"
logger1.info "Tadaaa 1"
logger2.info "Tadaaa 2"
logger3.info "Tadaaa 3"
Hi, how can I set the facility to LOCAL4?
Thanks !!!
In remote_syslog_logger/lib/remote_syslog_logger.rb I can see ...
require 'logger'
.
.
.
def self.new(remote_hostname, remote_port, options = {})
Logger.new(RemoteSyslogLogger::UdpSender.new(remote_hostname, remote_port, options))
end
What option could be?
#!/usr/bin/env ruby
require 'aws-sdk'
require 'remote_syslog_logger'
logger = RemoteSyslogLogger.new('192.168.1.40', 514)
logger.info("Program started")
Would like to be able to also send logs via TCP/TLS, not just UDP. Is there any reason that this is not currently supported by this library?
I have implemented RemoteSyslogLogger
successfully for the most part, but with one of the implementation points I am getting this error:
RemoteSyslogLogger::UdpSender error: IOError: closed stream
without any additional details (other than "original message").
Any idea how to debug this?
For context, it happens only on my DelayedJob
process, which was also set to use RemoteSyslogLogger
.
Also, the configuration of the RemoteSyslogLogger
seems to be ok, and I was able to even send an event manually by using DelayedJob::Worker.logger.info
More details in the question I opened in StackOverflow - with easy reproduction steps:
Most notably, the Hash.getopt monkey-patch is gone, so initialize
now crashes.
See the full diff for logging:
TwP/logging@c1025b6...f7bcda5
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.