Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.02k stars 1.9k forks source link

Log Message is truncated #1891

Closed revoltek-daniel closed 4 months ago

revoltek-daniel commented 5 months ago

Monolog version 2.9.3

We use Monolog in our Sylius Shop, sometimes we get Messages which are truncated.

This is how it should look:

[2024-05-29T12:27:06.472277+02:00] saferpay.DEBUG: Webhook handled successfully [] [] [2024-05-29T12:27:13.159350+02:00] saferpay.DEBUG: Handling webhook started [] [] [2024-05-29T12:27:13.163790+02:00] saferpay.DEBUG: PrepareCaptureAction: Synchronous processing started [] [] [2024-05-29T12:27:13.177069+02:00] saferpay.DEBUG: Synchronous processing PrepareCaptureAction succeeded [] []

Log file output:

[2024-05-29T12:27:13.793507+02:00] saferpay.DEBUG: Webhook handled successfully [] [] ous processing PrepareAssertAction succeeded [] [] [2024-05-29T12:27:14.063790+02:00] saferpay.DEBUG: PrepareCaptureAction: Synchronous processing started [] []

Monolog config:

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
            excluded_http_codes: [404, 405]
        nested:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: warning
        saferpay:
            type: rotating_file
            path: "%kernel.logs_dir%/saferpay.log"
            level: debug
            channels: ["saferpay"]
            max_files: 90

Is this a bug or have we done something wrong with our configuration?

Seldaek commented 4 months ago

The config looks fine.. You could try to enable useLocking in RotatingFileHandler's constructor (use_locking: true in symfony config), that should ensure two concurrent processes cannot write to the same at the same time, which I guess is what is happening here, but I have never seen such problems even in prod envs with quite a lot of traffic so I am unsure what's the underlying cause.