gpt4 book ai didi

yii2 - 登录在 yii2 中不起作用

转载 作者:行者123 更新时间:2023-12-05 08:12:04 35 4
gpt4 key购买 nike

我想在 app.log 中添加一个日志,我的配置文件

 'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
'file' => [
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
'logFile' => '@root/console/runtime/logs/app.log',
],
]
]

在 Controller Action 中

 public function actionRankCalculation()
{
$allConest = Contest::find()->where('isActive = 1')->all();
Yii::trace('start calculating average revenue');
$response = [];
/** @var Contest $contest */
foreach ($allConest as $contest) {
$videoQuery = Video::find()->where('contest_id = ' . $contest->id);
$videoQuery->andWhere('isActive = 1');
$videoQuery->orderBy([
'global_likes' => SORT_DESC,
'id' => SORT_ASC,
]);

}但是 Yii::trace('开始计算平均收入');不工作

最佳答案

你试试这个。使用类别。例如像下面

            'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error'],
'categories' => ['test1'],
'logFile' => '@app/Test/test1.log',


],

并在 Controller Action 中使用下面的一个

 public function actionIndex(){    
Yii::error('Test index action', $category = 'test1'); }

关于yii2 - 登录在 yii2 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39871779/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com