默认情况下,laravel将日志(log)文件保存到名为laravel.log的单个日志(log)文件中,该日志(log)文件位于/storage/logs/laravel.log

my question is how can i get a new log file everyday and store the log files like /storage/logs/laravel-2016-02-23.log for the current date, so i need everyday a new log file saved to /storage/logs/

i think we can do that by extending the default Illuminate\Foundation\Bootstrap\ConfigureLogging bootstraper class but i'm not sure how i can do that

如果有人能帮我,我将不胜感激.

Thanks in advance.

推荐答案

其实要简单得多.在你的config/app.php中,你会看到一行:

'log' => 'single',

靠近文件底部.默认情况下,Laravel使用single方法,将所有错误存储在一个扩展文件中.如果将此行更改为:

'log' => 'daily',

it will tell Laravel that you'd prefer to have multiple logs, each suffixed with the date of the when the error occurs.

There's a few other methods available, so be sure to check out the official documentation for more info.


此答案适用于Laravel 5.2,这是原始问题中指定的版本.在Laravel的Never版本中,日志(log)配置已被移到它自己的配置文件中,如@ShanthaKumara的回答(https://stackoverflow.com/a/51816907/3965631)所示.请不要建议进行编辑以更改此答案以反映新版本.

Laravel相关问答推荐

保存很多模型太慢

Laravel FAKER语法

laravel Eloquent 模型更新事件未触发

"public/index.php" 可以在 laravel 中按组写入

在 laravel 4.2 中,用户 'root'@'localhost' 的 Laravel 访问被拒绝(使用密码:YES)

Laravel 错误ReflectionException-类 App\Http\Kernel 不存在

Laravel 5.1 - 如何在进度条上设置消息

从 laravel/blade 中的数组创建逗号分隔列表?

升级到 laravel 5.4 后调用未定义的方法

Laravel 5 - 没有重叠的任务计划不起作用

致命错误:找不到类App\Http\Controllers\Redirect

Laravel timestamps() 不会创建 CURRENT_TIMESTAMP

Laravel 从现有模型生成迁移

如何在 laravel 中解码 Json 对象并在 laravel 中应用 foreach 循环

为什么 BroadCastEvent 在 Laravel 中排队?如何阻止它?

命令未定义异常

Laravel - 动态创建表(无需迁移)

是否可以在 Laravel 的不同数据库中引用外键?

在 Laravel 中判断会话超时

在 Laravel 中翻译特定语言