Log::Log4perl::Layout::GELF - Log4perl for graylog2
Version 0.03
Log4perl implementation of GELF. When used with Log::Log4perl::Appender::Socket you can log directly to a graylog2 server.
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.
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"); ...
Can take most of options that Log::Log4perl::Layout::PatternLayout can. Additional Options: PlainText - outputs plaintext and not gzipped files.
Wraps the Log::Log4perl::Layout::PatternLayout return value so we can gzip the JSON string.
To install Log::Log4perl::Layout::GELF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Log4perl::Layout::GELF
CPAN shell
perl -MCPAN -e shell install Log::Log4perl::Layout::GELF
For more information on module installation, please visit the detailed CPAN module installation guide.