【发布时间】:2013-12-11 09:10:28
【问题描述】:
你好
我正在尝试为 Laravel 4 编写一个自定义包,以执行一些额外的日志记录。根据 Laravel 文档 (http://laravel.com/docs/errors),我可以创建一个侦听器并在 Closure 中做我需要做的事情。
这是ServiceProvider里面的注册函数
使用日志;
public function register()
{
Log::listen(function($level, $message, $context)
{
$vmlog = new Vmlog();
$vmlog->log($level, $message, $context);
});
}
我收到以下错误:
Call to undefined method Illuminate\Support\Facades\Log::listen()
这是别名条目(我没有更改)。
'aliases' => array(
...
'Log' => 'Illuminate\Support\Facades\Log',
...
),
这里哪里出错了,为什么我不能访问listen()函数?
【问题讨论】: