我使用'队列'扩展的yii2框架。这个扩展可能会失败,这是保存在日志文件中,我想在一个特定的视图中查看错误。我能够将错误记录到特定的.log文件中,因此真正的问题是,如何从另一个日志文件查看错误?
Yii框架使用分类区分日志文件
配置:
return [
'bootstrap' => ['log'],
'timeZone' => 'PRC',
'components' => [
'log' => [
'targets' => [
//default
[
'class' => 'yiilogDbTarget',
'levels' => ['error', 'warning'],
],
//especially
[
'class' => 'yiilogDbTarget',
'levels' => ['error'],
'categories' => ['yiidb*'],//The point
'logFile'=>'log.txt',//you custom file
],
//especially2
[
'class' => 'yiilogDbTarget',
'levels' => ['error'],
'categories' => ['appmodels'],//The point
'logFile'=>'log.txt',//you custom file
],
//especially3
[
'class' => 'yiilogDbTarget',
'levels' => ['error'],
'categories' => ['abc'],//The point
'logFile'=>'log.txt',//you custom file
],
],
],
],
);
使用它<>以前Yii:跟踪(db错误);Yii::trace('开始计算平均收入',__METHOD__);Yii::trace('start calculation average revenue', 'abc');'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yiilogFileTarget',
'levels' => ['error', 'warning'],
],
'error' =>
[
'class' => 'yiilogFileTarget',
'levels' => ['error', 'warning'],
'categories' => ['yiiqueueQueue'],
'logFile' => '@runtime/logs/error.log',
//'enabled' => YII_DEBUG,
//'exportInterval' => 1,
],
],
],