Home > PHP Framework > YII > Where are yii error messages recorded?

Where are yii error messages recorded?

Release: 2019-12-14 11:36:15
Original
3005 people have browsed it

Where are yii error messages recorded?

yiiError information is recorded in the database. Let’s take a look at how to use the database to record error information.

Command line to create error log table

1, configuration file: console\config\main.php

'components' => [
    'log' => [
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
            ],
            [
                'class' => 'yii\log\DbTarget',  //使用数据库记录日志                'levels' => ['error', 'warning'],
            ]           
        ],
    ]
],
Copy after login

2, cd to the project root directory, in common After the module has configured the database configuration, execute the command line to create the table:

php yii migrate --migrationPath=@yii/log/migrations/

Modify the configuration file: backend\config\main.php

'components' => [
    ... ...
    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
            ],
            [
                'class' => 'yii\log\DbTarget',  //使用数据库记录日志                'levels' => ['error', 'warning'],
            ]
        ],
    ],
    ... ...
]
Copy after login

Recommended related articles and tutorials: yii framework tutorial

The above is the detailed content of Where are yii error messages recorded?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template