2017 © Pedro Peláez
 

symfony-bundle monolog-browser-bundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

image

lexik/monolog-browser-bundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  • Friday, March 31, 2017
  • by jeremyb
  • Repository
  • 16 Watchers
  • 64 Stars
  • 52,044 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 21 Forks
  • 8 Open issues
  • 7 Versions
  • 3 % Grown

The README.md

LexikMonologBrowserBundle

Build Status Latest Stable Version SensioLabsInsight, (*1)

This Bundle is deprecated

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries. You can list, filter and paginate logs as you can see on the screenshot bellow:, (*2)

Log entries listing Log entry show, (*3)

As this bundle query your database on each raised log, it's relevant for small and medium projects, but if you have billion of logs consider using a specific log server like sentry, airbrake, etc., (*4)

Requirements:

  • Symfony 2.1+
  • KnpLabs/KnpPaginatorBundle

Installation

Installation with composer:, (*5)

``` json ... "require": { ... "lexik/monolog-browser-bundle": "~1.0", ... }, ..., (*6)


Next, be sure to enable these bundles in your `app/AppKernel.php` file: ``` php public function registerBundles() { return array( // ... new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(), new Lexik\Bundle\MonologBrowserBundle\LexikMonologBrowserBundle(), // ... ); }

Configuration

First of all, you need to configure the Doctrine DBAL connection to use in the handler. You have 2 ways to do that:, (*7)

By using an existing Doctrine connection:, (*8)

Note: we set the logging and profiling option to false to avoid DI circular reference., (*9)

``` yaml, (*10)

app/config/config.yml

doctrine: dbal: connections: default: ... monolog: driver: pdo_sqlite dbname: monolog path: %kernel.root_dir%/cache/monolog2.db charset: UTF8 logging: false profiling: false, (*11)

lexik_monolog_browser: doctrine: connection_name: monolog, (*12)


**By creating a custom Doctrine connection for the bundle:** ``` yaml # app/config/config.yml lexik_monolog_browser: doctrine: connection: driver: pdo_sqlite driverClass: ~ pdo: ~ dbname: monolog host: localhost port: ~ user: root password: ~ charset: UTF8 path: %kernel.root_dir%/db/monolog.db # The filesystem path to the database file for SQLite memory: ~ # True if the SQLite database should be in-memory (non-persistent) unix_socket: ~ # The unix socket to use for MySQL

Please refer to the Doctrine DBAL connection configuration for more details., (*13)

Optionally you can override the schema table name (monolog_entries by default):, (*14)

``` yaml, (*15)

app/config/config.yml

lexik_monolog_browser: doctrine: table_name: monolog_entries, (*16)


Now your database is configured, you can generate the schema for your log entry table by running the following command:

./app/console lexik:monolog-browser:schema-create, (*17)

you should see as result:

Created table monolog_entries for Doctrine Monolog connection


Then, you can configure Monolog to use the Doctrine DBAL handler: ``` yaml # app/config/config_prod.yml # or any env monolog: handlers: main: type: fingers_crossed # or buffer level: error handler: lexik_monolog_browser app: type: buffer action_level: info channels: app handler: lexik_monolog_browser deprecation: type: buffer action_level: warning channels: deprecation handler: lexik_monolog_browser lexik_monolog_browser: type: service id: lexik_monolog_browser.handler.doctrine_dbal

Now you have enabled and configured the handler, you migth want to display log entries, just import the routing file:, (*18)

``` yaml, (*19)

app/config/routing.yml

lexik_monolog_browser: resource: "@LexikMonologBrowserBundle/Resources/config/routing.xml" prefix: /admin/monolog, (*20)


Translations ------------ If you wish to use default translations provided in this bundle, make sure you have enabled the translator in your config: ``` yaml # app/config/config.yml framework: translator: ~

Overriding default layout

You can override the default layout of the bundle by using the base_layout option:, (*21)

``` yaml, (*22)

app/config/config.yml

lexik_monolog_browser: base_layout: "LexikMonologBrowserBundle::layout.html.twig", (*23)


or quite simply with the Symfony way by create a template on `app/Resources/LexikMonologBrowserBundle/views/layout.html.twig`. Updating the bundle ------------------- At each bundle updates, be careful to potential schema updates and because Monolog entries table is disconnected from the rest of your Doctrine entities or models, you have to manualy update the schema. The bundle comes with a `schema-update` command but in some cases, like on renaming columns, the default behavior is not perfect and you may have a look to Doctrine Migrations (you can read an example on PR #2). You can execute the command below to visualize SQL diff and execute schema updates:

./app/console lexik:monolog-browser:schema-update ```, (*24)

ToDo

  • configure Processors to push into the Handler
  • abstract handler and connector for Doctrine and browse another like Elasticsearh
  • write Tests

The Versions

31/03 2017

dev-master

9999999-dev https://github.com/lexik/LexikMonologBrowserBundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

logger monolog symfony2 bundle doctrine

27/09 2016

v1.0.2

1.0.2.0 https://github.com/lexik/LexikMonologBrowserBundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

logger monolog symfony2 bundle doctrine

12/01 2016

dev-sf2.8-3.0

dev-sf2.8-3.0 https://github.com/lexik/LexikMonologBrowserBundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

logger monolog symfony2 bundle doctrine

22/10 2015

v1.0.1

1.0.1.0 https://github.com/lexik/LexikMonologBrowserBundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

logger monolog symfony2 bundle doctrine

29/05 2015

v1.0.0

1.0.0.0 https://github.com/lexik/LexikMonologBrowserBundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

logger monolog symfony2 bundle doctrine

25/05 2013

dev-doctrine_connection

dev-doctrine_connection https://github.com/lexik/LexikMonologBrowserBundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

logger monolog symfony2 bundle doctrine

25/05 2013

v0.1.0

0.1.0.0 https://github.com/lexik/LexikMonologBrowserBundle

This Symfony2 bundle provides a Doctrine DBAL handler for Monolog and a web UI to display log entries

  Sources   Download

MIT

The Requires

 

The Development Requires

logger monolog symfony2 bundle doctrine