Skip to content

Commit 7abafec

Browse files
committed
Added app monolog channel
1 parent 8ce9fc1 commit 7abafec

7 files changed

Lines changed: 85 additions & 366 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@
3333
###> phpstan/phpstan ###
3434
phpstan.neon
3535
###< phpstan/phpstan ###
36+
37+
docs

config/packages/monolog.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
monolog:
22
channels:
33
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
4+
- app # Application-level errors (business logic), logged with extra context
45

56
when@dev:
67
monolog:
@@ -9,11 +10,16 @@ when@dev:
910
type: stream
1011
path: "%kernel.logs_dir%/%kernel.environment%.log"
1112
level: debug
12-
channels: ["!event"]
13+
channels: ["!event", "!app"]
1314
console:
1415
type: console
1516
process_psr_3_messages: false
1617
channels: ["!event", "!doctrine", "!console"]
18+
app:
19+
type: stream
20+
path: "%kernel.logs_dir%/app.log"
21+
level: debug
22+
channels: [app]
1723

1824
when@test:
1925
monolog:
@@ -37,11 +43,11 @@ when@prod:
3743
action_level: error
3844
handler: nested
3945
excluded_http_codes: [404, 405]
40-
channels: ["!deprecation"]
46+
channels: ["!deprecation", "!app"]
4147
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
4248
nested:
4349
type: stream
44-
path: php://stderr
50+
path: "%kernel.logs_dir%/%kernel.environment%.log"
4551
level: debug
4652
formatter: monolog.formatter.json
4753
console:
@@ -51,5 +57,11 @@ when@prod:
5157
deprecation:
5258
type: stream
5359
channels: [deprecation]
54-
path: php://stderr
60+
path: "%kernel.logs_dir%/deprecation.log"
61+
formatter: monolog.formatter.json
62+
app:
63+
type: stream
64+
channels: [app]
65+
path: "%kernel.logs_dir%/app.log"
66+
level: debug
5567
formatter: monolog.formatter.json

config/services.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ services:
5555

5656
# add more service definitions when explicit configuration is needed
5757
# please note that last definitions always *replace* previous ones
58+
App\Monolog\AppContextProcessor:
59+
tags:
60+
- { name: monolog.processor, channel: app }

0 commit comments

Comments
 (0)