Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 6b1719a

Browse files
committed
refactor(config): Migrate monolog.yaml to PHP
1 parent ed50e9c commit 6b1719a

File tree

2 files changed

+66
-62
lines changed

2 files changed

+66
-62
lines changed

config/packages/monolog.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
6+
use Symfony\Config\MonologConfig;
7+
8+
return static function (ContainerConfigurator $containerConfigurator, MonologConfig $monologConfig): void {
9+
$monologConfig->channels(['deprecation']);
10+
11+
if ('dev' === $containerConfigurator->env()) {
12+
$monologConfig->handler('main')
13+
->type('stream')
14+
->path('%kernel.logs_dir%/%kernel.environment%.log')
15+
->level('debug')
16+
->channels()
17+
->elements(['!event']);
18+
$monologConfig->handler('console')
19+
->type('console')
20+
->processPsr3Messages(false)
21+
->channels()
22+
->elements(['!event', '!doctrine', '!console']);
23+
}
24+
25+
if ('test' === $containerConfigurator->env()) {
26+
$monologConfig->handler('main')
27+
->type('fingers_crossed')
28+
->actionLevel('error')
29+
->handler('nested')
30+
->excludedHttpCode(404)
31+
->excludedHttpCode(405)
32+
->channels()
33+
->elements(['!event']);
34+
$monologConfig->handler('nested')
35+
->type('stream')
36+
->path('%kernel.logs_dir%/%kernel.environment%.log')
37+
->level('debug');
38+
}
39+
40+
if ('prod' === $containerConfigurator->env()) {
41+
$monologConfig->handler('main')
42+
->type('fingers_crossed')
43+
->actionLevel('error')
44+
->handler('nested')
45+
->excludedHttpCode(404)
46+
->excludedHttpCode(405)
47+
// How many messages should be saved? Prevent memory leaks
48+
->bufferSize(50);
49+
$monologConfig->handler('nested')
50+
->type('stream')
51+
->path('php://stderr')
52+
->level('debug')
53+
->formatter('monolog.formatter.json');
54+
$monologConfig->handler('console')
55+
->type('console')
56+
->processPsr3Messages(false)
57+
->channels()
58+
->elements(['!event', '!doctrine']);
59+
$monologConfig->handler('deprecation')
60+
->type('stream')
61+
->path('php://stderr')
62+
->formatter('monolog.formatter.json')
63+
->channels()
64+
->elements(['deprecation']);
65+
}
66+
};

config/packages/monolog.yaml

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)