【问题标题】:Laravel sentry set environmentLaravel 哨兵设置环境
【发布时间】:2020-03-10 09:21:05
【问题描述】:

我正在为我的项目设置哨兵,我目前有 3 个本地环境、暂存环境和生产环境。

我只想将其设置为哨兵跟踪登台和制作,我们完全忽略本地,但通过查看文档我没有找到任何帮助我的东西。

处理方法

此方法直接取自文档并添加到我的处理程序方法中

public function report(Exception $exception)
{
    if (app()->bound('sentry') && $this->shouldReport($exception)) {
        app('sentry')->captureException($exception);
    }

    parent::report($exception);
}

哨兵配置

return [

'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),

// capture release as git sha
// 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')),

'breadcrumbs' => [
    // Capture Laravel logs in breadcrumbs
    'logs' => true,

    // Capture SQL queries in breadcrumbs
    'sql_queries' => true,

    // Capture bindings on SQL queries logged in breadcrumbs
    'sql_bindings' => true,

    // Capture queue job information in breadcrumbs
    'queue_info' => true,
],

];

环境文件

SENTRY_DSN=dsdsdsds

有人对如何设置它以跟踪某些环境有任何指导吗?我是否需要设置任何额外的 env 键?

【问题讨论】:

    标签: laravel sentry


    【解决方案1】:

    如果您在本地 .env 中将 SENTRY_DSN= 设置为 null 或将其删除,它将永远不会被发送出去,因为 DSN 丢失所以无处可发送。

    https://docs.sentry.io/platforms/php/laravel/#local-development

    【讨论】:

    • 我明白这一点,但我想跟踪登台和制作
    • 对于暂存和生产,您应该为 SENTRY_DSN= 设置正确的 dns。它们都应该有一个单独的 .env 文件。
    猜你喜欢
    • 2016-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-21
    • 2017-07-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多