From 7eea7437d76d50a263b412e99e491f3528330bc7 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 7 Dec 2023 00:14:17 +0200 Subject: [PATCH] add monolog-bundle --- composer.json | 1 + config/bundles.php | 1 + config/packages/monolog.yaml | 61 ++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 config/packages/monolog.yaml diff --git a/composer.json b/composer.json index 77db457..7a85f18 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "symfony/dotenv": "7.0.*", "symfony/flex": "^2", "symfony/framework-bundle": "7.0.*", + "symfony/monolog-bundle": "^3.10", "symfony/runtime": "7.0.*", "symfony/translation": "7.0.*", "symfony/twig-bundle": "7.0.*", diff --git a/config/bundles.php b/config/bundles.php index 4ce0d70..70982cc 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -4,4 +4,5 @@ return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], ]; diff --git a/config/packages/monolog.yaml b/config/packages/monolog.yaml new file mode 100644 index 0000000..3c3a766 --- /dev/null +++ b/config/packages/monolog.yaml @@ -0,0 +1,61 @@ +monolog: + channels: + - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists + +when@dev: + monolog: + handlers: + main: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + channels: ["!event"] + # uncomment to get logging in your browser + # you may have to allow bigger header sizes in your Web server configuration + #firephp: + # type: firephp + # level: info + #chromephp: + # type: chromephp + # level: info + console: + type: console + process_psr_3_messages: false + channels: ["!event", "!doctrine", "!console"] + +when@test: + monolog: + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + excluded_http_codes: [404, 405] + channels: ["!event"] + nested: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + +when@prod: + monolog: + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + excluded_http_codes: [404, 405] + buffer_size: 50 # How many messages should be saved? Prevent memory leaks + nested: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + formatter: monolog.formatter.json + console: + type: console + process_psr_3_messages: false + channels: ["!event", "!doctrine"] + deprecation: + type: stream + channels: [deprecation] + path: php://stderr