Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wassy83's avatar

Cannot change date format when using JsonFormatter in logs

I have in my logging.php this channel

        'events' => [
            'driver' => 'monolog',
            'path' => storage_path('logs/events.log'),
            'level' => 'info',
            'formatter' => Monolog\Formatter\JsonFormatter::class,
            'formatter_with' => [
                'dateFormat' => 'Y-m-d',
            ]
        ]

if I try to log with

Log::channel('events')->info("my message");

the date format doesn't affects the json, so I always have datetime part in this format

"datetime":"2022-11-22T11:57:11.202195+01:00"

if I use the LineFormatter the date is formatted as I declare in dateFormat

0 likes
2 replies

Please or to participate in this conversation.