DockerLogsBundle is intended for containerized Symfony applications whose logs you would like to redirect stderr
for use with either docker logs
or docker-compose logs
, but without tampering with the normal output to stderr
of Symfony commands ran manually, not as a service.
- Automatic redirect of non cli processes like web server or queue consumer to
stderr
. - Configurable level for each Monolog channel with an env var like
LOGGIN_APP=debug
. - Decorated console formatter.
Open a command console, enter your project directory and execute:
$ composer require chrif/docker-logs-bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require chrif/docker-logs-bundle
This 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:
Make sure to place it above Monolog.
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new \Chrif\Bundle\DockerLogsBundle\ChrifDockerLogsBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
);
// ...
}
// ...
}
chrif_docker_logs:
# Each channel will have a configurable logging level through an env var named 'env_prefix' + 'channel'. Example: LOGGING_APP
channels:
# Defaults:
- app
- event
- doctrine
- console
- php
# Default logging level for all channels in 'channels'.
default_logging_level: notice
# These channels will be muted in a Symfony command without the --'docker-logs' option.
channels_to_ignore_in_console:
# Defaults:
- event
- doctrine
- console
# This is the prefix for the env vars.
env_prefix: LOGGING_
# If true, all channels not listed in 'channels' will have the LOGGING_OTHER level which defaults to 'debug'. Useful for finding new channels to add in the 'channels' config.
create_other_handler: true
# If true, use a decorated (colored) console output (when available).
colors: true