❗ This package is abandoned and no longer actively maintained.
Symfony bundle with extra processors and logger to log request/response/command.
Open a command console, enter your project directory and execute:
$ composer require thereddot/monolog-extra-bundleOpen a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require thereddot/monolog-extra-bundleThis command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new TheRedDot\MonologExtraBundle\TheRedDotMonologExtraBundle(),
);
// ...
}
// ...
}The bundle provides several processors:
- User
- Session id
- Request id
- Additions
The UserProcessor add data about the current user in each log entry.
the_red_dot_monolog_extra:
processor:
user: trueThe default provider SymfonyUserProvider returns:
- anonymous when no user is logged
- the username of the current logged user
- cli
You can customize the provider to replace the username by another property:
TheRedDot\MonologExtraBundle\Provider\User\SymfonyUserProvider:
arguments:
$className: App\Entity\User
$propertyName: myCustomPropertyYou can create your own provider by creating a service that implements TheRedDot\MonologExtraBundle\Provider\User\UserProviderInterface.
the_red_dot_monolog_extra:
provider:
user: your_own_provider_service_idAdd the session id in each log entry.
the_red_dot_monolog_extra:
session_start: false
processor:
session_id: trueYou can create your own provider by creating a service that implements TheRedDot\MonologExtraBundle\Provider\Session\SessionIdProviderInterface.
the_red_dot_monolog_extra:
provider:
session_id: your_own_provider_service_idAdd the request id for the request in each log entry.
the_red_dot_monolog_extra:
processor:
request_id: trueThe bundle comes with 2 providers:
- UniqidProvider (default): use
uniqid - ServerRequestIdProvider: get from
$_SERVER- you need to pass the name of a field of
$_SERVER, example for mod_unique_id of Apache:UNIQUE_ID.
- you need to pass the name of a field of
You can create your own provider by creating a service that implements TheRedDot\MonologExtraBundle\Provider\RequestId\RequestIdProviderInterface.
the_red_dot_monolog_extra:
provider:
request_id: your_own_provider_service_idAdd custom data in each log entry.
the_red_dot_monolog_extra:
processor:
additions:
type: symfony
application: the best symfony application
locale: "%locale%"
environment: "%kernel.environment%"Create a log entry with the request data.
Create a log entry with the response data.
Create a log entry before executing any command.
Create a log entry when an exception occurs in console.
Add the request id of the previous processor in the response headers.
HTTP/1.1 302 Found
X-Request-ID: 57c5f5e842b10
Configuration reference for a reference on the available configuration options.
Forked from Hexanet/MonologExtraBundle.
MonologExtraBundle is licensed under the MIT license.

