首页 文章

Laravel 5.1 Logger 时区

提问于
浏览
0

有没有办法可以改变Laravel 5.1 Logger 的时区?我'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'看起来像 LogServiceProvider 已经被使用了 .

我看到 app.php 文件中有一个 timezone 键,但我不希望整个系统发生变化 . 我只想更新日志的时区,并保持系统的其余部分为UTC .

1 回答

  • 2

    我刚看到你的回复,我真的很简单 . 创建一个新的服务提供者并在 config/app.php 中注册它,然后将以下行添加到 boot 方法 .

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

    确保在服务提供商的顶部包含 Logger 类 .

    您可以从此列表中将时区设置为您想要的任何一个区域,http://php.net/manual/en/timezones.php

相关问题