The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Log::Log4perl::Appender::Elasticsearch - implements appending to Elasticsearch

DESCRIPTION

This is a simple appender for writing log entries to Elasticsearch via Index API.

Log::Log4perl::Appender::Elasticsearch::Bulk does the same task by using Bulk API.

VERSION

Version 0.09

SYNOPSIS

    use Log::Log4perl;

    Log::Log4perl->init(\<<'HERE');
    log4perl.logger=DEBUG, ES

    log4perl.appender.ES = Log::Log4perl::Appender::Elasticsearch
    log4perl.appender.ES.layout = Log::Log4perl::Layout::NoopLayout

    log4perl.appender.ES.body.level = %p
    log4perl.appender.ES.body.module = %M
    log4perl.appender.ES.body.line = %L

    log4perl.appender.ES.nodes = localhost:9200
    log4perl.appender.ES.index = log4perl
    log4perl.appender.ES.type = entry

    log4perl.appender.ES.use_https = 0
    log4perl.appender.ES.user_agent.timeout = 5

    log4perl.appender.ES.headers.User-Agent = foo
    HERE

    Log::Log4perl::get_logger()->info("OK");

    # look up:
    # curl -XPOST 'http://localhost:9200/log4perl/_search' -d \
    # '{"query": {"query_string": {"query": "level:INFO AND message:OK"}}}'
    # ...
    #         "_source": {
    #           "module": "main::__ANON__",
    #           "line": "60",
    #           "level": "INFO",
    #           "message": "OK"
    #        }

OPTIONS

  • nodes

    a comma separeted list of nodes. The message will be sent to the next node only if previous request failed

  • index

    The name of the elasticsearch index the message will be stored in.

  • type

    The name of the type in given index the message belongs to.

  • use_https

    0|1 global https setting for all nodes

    the individual https setting possible too:

    log4perl.appender.ES.nodes = https://user:password@node1:9200,localhost:9200

  • user_agent

    LWP::UserAgent parameters

    log4perl.appender.ES.user_agent.timeout = 5

  • headers

    HTTP::Headers parameters

    log4perl.appender.ES.headers.User-Agent = foo

AUTHOR

Alexei Pastuchov <palik at cpan.org>

REPOSITORY

https://github.com/p-alik/Log-Log4perl-Appender-Elasticsearch.git

LICENSE AND COPYRIGHT

Copyright 2014, 2015 by Alexei Pastuchov <palik at cpan.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.