NAME
Log::Log4perl::Layout::GELF - Log4perl for graylog2
VERSION
Version 0.03
SYNOPSIS
Log4perl implementation of GELF. When used with Log::Log4perl::Appender::Socket you can log directly to a graylog2 server.
What is graylog?
Graylog is log management server that can be used to run analytics, alerting, monitoring and perform powerful searches over your whole log base. Need to debug a failing request? Just run a quick filter search to find it and see what errors it produced. Want to see all messages a certain API consumer is consuming in real time? Create streams for every consumer and have them always only one click away.
Configuration Sample
Code snippet. Replace the ip with your graylog server.
use Log::Log4perl
my $logger_conf = {
'log4perl.logger.graylog' => "DEBUG, SERVER",
'log4perl.appender.SERVER' => "Log::Log4perl::Appender::Socket",
'log4perl.appender.SERVER.PeerAddr' => '10.211.1.94',
'log4perl.appender.SERVER.PeerPort' => "12201",
'log4perl.appender.SERVER.Proto' => "udp",
'log4perl.appender.SERVER.layout' => "GELF"
};
Log::Log4perl->init( $logger_conf );
my $LOGGER = Log::Log4perl->get_logger('graylog');
$LOGGER->debug("Debug log");
...
SUBROUTINES/METHODS
new
Can take most of options that Log::Log4perl::Layout::PatternLayout can.
Additional Options:
PlainText - outputs plaintext and not gzipped files.
render
Wraps the Log::Log4perl::Layout::PatternLayout return value so we can
gzip the JSON string.