Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.1 Logger Timezone

Is there a way I can change the timezone for the Laravel 5.1 logger? I've seen previous discussions where they extended the Monolog class and updated the Service Provider, but that was for an older version of Laravel and it doesn't look like the LogServiceProvider is used anymore.

I see there's a timezone key in the app.php file, but I don't want the whole system to change. I just want to update the timezone for the logs, and keep the rest of the system in UTC.

like image 621
kenshin9 Avatar asked Oct 28 '25 14:10

kenshin9


1 Answers

I just saw your reply, I've figured it out and it's really simple. Create a new service provider and register it in config/app.php then add the following line to the boot method.

Logger::setTimezone(new \DateTimeZone('PST'));

Make sure you include the Logger class at the top of your service provider.

You may set the timezone to whichever one you'd like from this list, http://php.net/manual/en/timezones.php

like image 98
tomirons Avatar answered Oct 30 '25 05:10

tomirons