Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sentry 日志平台 #10

Open
jamesBan opened this issue Aug 7, 2019 · 0 comments
Open

sentry 日志平台 #10

jamesBan opened this issue Aug 7, 2019 · 0 comments
Labels

Comments

@jamesBan
Copy link
Owner

jamesBan commented Aug 7, 2019

准备工作

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/

@jamesBan jamesBan added the 日志 label Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant