/ yii2

yii2-log

接入 Sentry

https://packagist.org/packages/notamedia/yii2-sentry

return [
    'components' => [
	    'log' => [
		    'traceLevel' => YII_DEBUG ? 3 : 0,
		    'targets' => [
			    [
				    'class' => 'notamedia\sentry\SentryTarget',
				    'dsn' => 'http://2682ybvhbs347:235vvgy465346@sentry.io/1',
				    'levels' => ['error', 'warning'],
				    'context' => true // Write the context information. The default is true.
			    ],
		    ],
	    ],
    ],
];

生产环境可以将上述内容加入 environments/prod/common/config/main-local.php 中。在生产环境中通过 php init 将文件复制到 common/config/main-local.php

Yii log skip 404 errors

For Yii 2.0, you can make your config/main.php like this:

return [
    'components' => [
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                    'except' => ['yii\web\HttpException:404'],
                ],
            ],
        ],
    ],
];