<!-- wp:heading {"level":5} -->
<h5>这里用到了一个国外第三方的日志分析平台(sentry)</h5>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>官方网站网址: sentry网址</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":5} -->
<h5>下面我们去github去下载yii2-sentry组件</h5>
<!-- /wp:heading -->

<!-- wp:heading {"level":5} -->
<h5>选择一个stars较多的并且目前还在更新维护中的。</h5>
<!-- /wp:heading -->

<!-- wp:image {"linkDestination":"custom"} -->
<figure class="wp-block-image">yii2-sentry</figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>然后去下载安装到自己框架中(这里不多介绍)</h5>
<!-- /wp:heading -->

<!-- wp:heading {"level":5} -->
<h5>主要看一下如何配置对接。</h5>
<!-- /wp:heading -->

<!-- wp:heading {"level":5} -->
<h5>点击自行注册登入(邮箱注册)</h5>
<!-- /wp:heading -->

<!-- wp:image {"linkDestination":"custom"} -->
<figure class="wp-block-image">点击自行注册</figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>创建项目</h5>
<!-- /wp:heading -->

<!-- wp:image {"linkDestination":"custom"} -->
<figure class="wp-block-image">https://niuzheng.net/wp-content/uploads/attach/201906/30_NTPV8Q4CEVNHBXT.png</figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>选择你的编程语言</h5>
<!-- /wp:heading -->

<!-- wp:image {"linkDestination":"custom"} -->
<figure class="wp-block-image">https://niuzheng.net/wp-content/uploads/attach/201906/30_VCASGM85QSU7DF5.png</figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>拿到key</h5>
<!-- /wp:heading -->

<!-- wp:image {"linkDestination":"custom"} -->
<figure class="wp-block-image">https://niuzheng.net/wp-content/uploads/attach/201906/30_NTPV8Q4CEVNHBXT.png</figure>
<!-- /wp:image -->

<!-- wp:heading {"level":5} -->
<h5>去Yii2的配置文件,配置如下,可以参考。</h5>
<!-- /wp:heading -->

<!-- wp:code -->

 'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
//                [
//                    'class' => 'yiilogFileTarget',
//                    'levels' => ['trace'],
//                    'logFile' => '@app/runtime/logs/shop/trace.log',
//                    'logVars' => ['_COOKIE'],
//                    'categories' => ['mylog'],
//                    'logVars' => [],
//                ],
//                [
//                    'class' => 'yiilogEmailTarget',
//                    'mailer' => 'mailer',
//                    'levels' => ['trace'],
//                    'categories' => ['mylog'],
//                    'message' => [
//                        'from' => ['17521181230@163.com'],
//                        'to' => ['17521181230@163.com'],
//                        'subject' => 'this is trace log',
//                    ],
//                ],
                [
                    'class' => 'notamediasentrySentryTarget',
                    'dsn' => 'https://e45054180b01821d72e26b8a2@sentry.io/1440272',
                    'levels' => ['error'],
                    'logVars' => [],
                    'context' => true // Write the context information. The default is true.
                ],
            ],

<!-- /wp:code -->

<!-- wp:heading {"level":5} -->
<h5>配置了错误等级和key,然后就可以了。</h5>
<!-- /wp:heading -->

<!-- wp:heading {"level":5} -->
<h5>效果如下:</h5>
<!-- /wp:heading -->

<!-- wp:image {"linkDestination":"custom"} -->
<figure class="wp-block-image">https://niuzheng.net/wp-content/uploads/attach/201906/30_EE3YH87U8RY68DM.png</figure>
<!-- /wp:image -->

关注友儿不迷路

Last modification:December 28th, 2019 at 08:55 pm
如果觉得我的文章对你有用,请随意赞赏