Skip to content

Commit bdc18de

Browse files
committed
feature #24300 [HttpKernel][FrameworkBundle] Add a minimalist default PSR-3 logger (dunglas)
This PR was squashed before being merged into the 3.4 branch (closes #24300). Discussion ---------- [HttpKernel][FrameworkBundle] Add a minimalist default PSR-3 logger | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This PR provides a minimalist PSR-3 logger that is always available when FrameworkBundle is installed. By default, it writes errors on `stderr`, regular logs on `stdout` and discards debug data (this is configurable). This approach has several benefits: - It's what expect from an app logging systems of major containerization and orchestration tools including [Docker](https://docs.docker.com/engine/admin/logging/view_container_logs/) and [Kubernetes](https://kubernetes.io/docs/concepts/cluster-administration/logging/), as well as most cloud providers such as [Heroku](https://devcenter.heroku.com/articles/logging#writing-to-your-log) and [Google Container Engine](https://kubernetes.io/docs/tasks/debug-application-cluster/logging-stackdriver/). If the app follows this standard (and it's not currently the case with Symfony by default) logs will be automatically collected, aggregated and stored. - It's in sync with the "back to Unix roots" philosophy of Flex - Logs are directly displayed in the console when running the integrated PHP web server (`bin/console server:start` or Flex's `make serve`), Create React App also do that for instance. - It fixes a common problem when installing Flex recipes: many bundles expect a logger service but currently there is none available by default, and you usually get a `"logger" service not found error` (because packages depend of the PSR, but the PSR doesn't provide a logger service). Commits ------- 9a06513ec7 [HttpKernel][FrameworkBundle] Add a minimalist default PSR-3 logger
2 parents dcc931e + dde60a2 commit bdc18de

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
3.4.0
55
-----
66

7+
* Always register a minimalist logger that writes in `stderr`
78
* Deprecated `profiler.matcher` option
89
* Added support for `EventSubscriberInterface` on `MicroKernelTrait`
910
* Removed `doctrine/cache` from the list of required dependencies in `composer.json`

FrameworkBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Component\Console\Application;
2929
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
3030
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
31+
use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass;
3132
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
3233
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;
3334
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
@@ -82,6 +83,7 @@ public function build(ContainerBuilder $container)
8283
{
8384
parent::build($container);
8485

86+
$container->addCompilerPass(new LoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
8587
$container->addCompilerPass(new RegisterControllerArgumentLocatorsPass());
8688
$container->addCompilerPass(new RemoveEmptyControllerArgumentLocatorsPass(), PassConfig::TYPE_BEFORE_REMOVING);
8789
$container->addCompilerPass(new RoutingResolverPass());

0 commit comments

Comments
 (0)