I’d like to override all of Laravel logger’s dateTimeZone to ‘Asia/Tokyo’, but not changing config/app.php => timezone
.
Laravel comes with monolog
library by default, and basically IlluminateLogLogManager
is doing all the work to instantiate MonologLogger
objects.
We can pass DateTimeZone
object to MonologLogger
constructor’s 4th argument, but there is no way we can pass that to LogManager
via config/logging.php
or anything.
I know that there’s a way to create custom logger object with full control and register to custom channel.
https://laravel.com/docs/8.x/logging#creating-custom-channels-via-factories
One way is that I’ll create & use AppLoggingCreateCustomLoggerWithTokyoTimeZone::class
and modify all of the default existing channels.
The other way is that I’ll somehow override LogManager
and bind it to service container ‘s log
service. (override log
service, but it’s a singleton)
Any good ideas? Anything is appreciated.