Skip to content

sentry 日志平台 #10

Open
Open
@jamesBan

Description

@jamesBan

准备工作

git clone https://github.com/getsentry/onpremise.git
cd onpremise
docker volume create --name=sentry-data && docker volume create --name=sentry-postgres
cp -n .env.example .env

构建

  • 构建docker镜像

    docker-compose build
    
  • 生成secret key,将其添加到配置文件.env中 (生成的secret key 会在最后一行)

    docker-compose run --rm web config generate-secret-key
  • 更新配置,其中会进行database migrate,最后会提示创建一个登录账号

     docker-compose run --rm web config generate-secret-key
  • 最后执行命令, 后台运行sentry server

    docker-compose up -d

    接着我们浏览器访问 localhost:9000 或者 server ip:9000,访问至登录页面即成功。

nginx

vim /etc/nginx/conf.d/sentry.conf

server{
    listen 80;
    server_name local.sentry.com;

    location / {
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:9000/;
    }
}

访问 local.sentry.com。

php项目集成

安装composer包

composer require sentry/sdk:2.0.3

创建测试文件test.php

<?php
  require "vendor/autoload.php";
  Sentry\init(['dsn' => 'http://492dc7167e724978b193911e123e05f7@localhost:9000/2' ]);
  throw new Exception("My first Sentry error!");

访问test.php 即可在senty内看到错误日志

参考

https://docs.sentry.io/error-reporting/quickstart/?platform=php

https://docs.sentry.io/server/installation/docker/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions