John Davidson

php - Symfony messenger is printing massive output through stderr

0 comments
Message:


I have a worker that needs to retry consuming some messages until an external service is available to store them, which is only available on work hours, but the events can be generated at any time.


Everything is working as expected, and I'm logging both stderr and stout for traceability purposes. This is a business decision and there's now way around it, so no .log files. But symfony messenger seems to be outputting massive amounts of data, mostly related to redelivery and delay stamps, and my logs are getting out of hand.


These outputs have no valuable information and seem to be serialized stamps. And there's thousands of them every hour:


:67:\\\"\\0Symfony\\\\Component\\\\Messenger\\\\Stamp\\\\RedeliveryStamp\\0...
:51:\\\"\\0Symfony\\\\Component\\\\Messenger\\\\Stamp\\\\DelayStamp\\0delay...

I have no custom middlewares and nothing is printed in my own code.


I tried configuring monolog to ignore messenger and doctrine related entries with no luck:


channels: ["!event", "!doctrine", "!messenger", "!security"]

This is what my messenger.yaml looks like:


framework:
messenger:
failure_transport: failed

transports:
failed: 'doctrine://default?queue_name=failed'
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
retry_strategy:
max_retries: 14400
delay: 300000
multiplier: 1
max_delay: 300000
options:
queue_name: redacted_queue_name
routing:
'App\Domain\UserCreatedEvent [async]

Am I missing some obvious way to disable this output?


Edit: this is what my monolog.yaml looks like:


monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
path: "php://stdout"
channels: ["!event", "!doctrine", "!messenger", "!security"]
nested:
type: stream
path: "php://stdout"
channels: ["!event", "!doctrine", "!messenger", "!security"]
console:
level: warning
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!messenger", "!security"]
deprecation:
type: stream
path: "php://stdout"
deprecation_filter:
type: filter
handler: deprecation
max_level: info
channels: ["php"]


My Answer:
This issue can be resolved by configuring the Symfony Messenger component to disable the serialization of stamps in the logs. You can do this by setting the `log_stamps` option to `false` in your Messenger configuration.

Here's an example of how you can configure this in your `config/packages/messenger.yaml` file:

yaml
framework:
messenger:
transports:
# your transport configuration here

routing:
# your message routing configuration here

failure_transport: failed

options:
log_stamps: false


By setting `log_stamps` to `false`, Symfony Messenger will no longer serialize stamps in the logs, which should reduce the amount of output and help keep your logs more manageable.

Rate this post

5 of 5 based on 5492 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us