Git Product home page Git Product logo

logstashmonologhandlerbundle's Introduction

Symfony2 Logstash handler for Monolog

Use in Symfony2 project with an ELK architecture, ie : https://github.com/pilebones/elk-stack-docker

## Requirements

  • Symfony2
  • Monolog
  • ELK (Logstash, Elasticsearch, Kibana)

Introduction

From Symfony2 application, this handler permit to send the Symfony2 logs stream to an instance of Logstash server.

This Handler aggregate all lines from a single Symfony2 request to push to Logstash inside only-one entry like UTF-8 JSON format.

/!\ Warning : Logstash must be configure with "input-tcp" with "input-codec-json" !

You can enrich log stream with some custom attributes (see bellow).

Installation

Edit composer.json :

    [...]
    "require" : {
        [...]
        "pilebones/logstash-bundle" : "dev-master"
    },
    "repositories" : [{
        "type" : "vcs",
        "url" : "https://github.com/pilebones/logstashMonologHandlerBundle.git"
    }],
    [...]

Run composer.phar to install the bundle :

php composer.phar update "pilebones/logstash-bundle"

Project settings

In app/AppKernel :

new Pilebones\LogstashBundle\PilebonesLogstashBundle(),

In app/config/config.yml :

imports:
    # [...]
    - { resource: pilebones_logstash.yml }

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
        nested:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            handler: logstash
        console:
            type:  console
        logstash:
            type: service
            id: pilebones_logstash.monolog.logstash_handler

In app/config/pilebones_logstash.yml :

pilebones_logstash:
	# Allowed format : http://php.net/manual/fr/transports.php
    logstash_address: tcp://localhost:25826
    
    # Optionnal parameters
    custom_log_attributes:
        corporate: MyOfficeName
        project: POC Sf2 vs Logstash 
        developper_name: pilebones

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.