3. @Configuration 里边加入:
@Bean public HandlerExceptionResolver sentryExceptionResolver() { return new io.sentry.spring.SentryExceptionResolver(); } @Bean public ServletContextInitializer sentryServletContextInitializer() { return new io.sentry.spring.SentryServletContextInitializer(); }4. resource 增加 sentry.properties (不是在application.properties 里)文件里边写入:
dsn=https://your-dsn-url@sentry.io/1464303
5. 调用:
private static LoggerAdapter logger = new LoggerAdapterFactory().getLoggerAdapter(some.class); logger.Info("abc");下边是安装sentry 的步骤:
Start a Redis container
$ docker run -d --name sentry-redis redisStart a Postgres container
$ docker run -d --name sentry-postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=sentry postgresGenerate a new secret key to be shared by all sentry containers. This value will then be used as the SENTRY_SECRET_KEYenvironment variable.
$ docker run --rm sentry config generate-secret-keyIf this is a new database, you’ll need to run upgrade (这一步要输入邮箱密码时间比较长)
$ docker run -it --rm -e SENTRY_SECRET_KEY='<secret-key>' --link sentry-postgres:postgres --link sentry-redis:redis sentry upgradeNote: the -it is important as the initial upgrade will prompt to create an initial user and will fail without it
Now start up Sentry server
$ docker run -d --name my-sentry -e SENTRY_SECRET_KEY='<secret-key>' --link sentry-redis:redis --link sentry-postgres:postgres sentry如果要改端口可以这样:
docker run -d -p 9000:9000 --name my-sentry -e SENTRY_SECRET_KEY='key' --link sentry-redis:redis --link sentry- postgres:postgres sentry
6. The default config needs a celery beat and celery workers, start as many workers as you need (each with a unique name)
$ docker run -d --name sentry-cron -e SENTRY_SECRET_KEY='<secret-key>' --link sentry-postgres:postgres --link sentry-redis:redis sentry run cron $ docker run -d --name sentry-worker-1 -e SENTRY_SECRET_KEY='<secret-key>' --link sentry-postgres:postgres --link sentry-redis:redis sentry run worker7. 127.0.0.1:9000 就可以进去了。
但是我进去后发现了dsn是空的,怎么办?
a.我把docker 还原出厂设置
b. https://github.com/getsentry/onpremise
c. 修改config.yml 增加
如下操作(写自己的ip地址:system.url-prefix: 'http://192.168.1.1.0:9000'):
I fixed this when I set the following code at config.yml
################### # System Settings # ###################
# If this file ever becomes compromised, it's important to regenerate your a new key # Changing this value will result in all current sessions being invalidated. # A new key can be generated with `$ sentry config generate-secret-key` # system.secret-key: 'changeme' system.url-prefix: 'http://my-sentry-host:9000'
Than
docker-compose stop
docker-compose build # Build the services again after updating docker-compose up -d # Recreate the services
d. 使用时用:{your-ip}:9000 进去
可以使用了。