++ed by:

1 PAUSE user

Author image Jason Pope
and 1 contributors


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.

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' => '',
      '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.