Skip to content

Commit 597689b

Browse files
committed
Added app monolog channel
1 parent 8ce9fc1 commit 597689b

6 files changed

Lines changed: 82 additions & 363 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: 14 additions & 2 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,7 +43,7 @@ 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
@@ -53,3 +59,9 @@ when@prod:
5359
channels: [deprecation]
5460
path: php://stderr
5561
formatter: monolog.formatter.json
62+
app:
63+
type: stream
64+
channels: [app]
65+
path: php://stderr
66+
level: debug
67+
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)