当前位置:网站首页>Centralized log management with sentry
Centralized log management with sentry
2022-07-28 08:58:00 【Brother Xing plays with the clouds】
In the debugger , Check by log stages BUG Is an important means , It can be said to be a sharp tool for program debugging .
About log management
With more application components , So each coder There are various kinds of output logs , There are writes stdout, Yes stderr, It was written syslog, Some also wrote xxx.log Of . Then this will cause the platform application logs to be distributed in various places , Unable to manage uniformly .
Why use Sentry
Sentry Is a centralized log management system . It has the following advantages :
- Multiple projects , Multi user
- Friendly interface
- Abnormal departure rules can be configured , E.g. send email
- Support for mainstream language interfaces
install
Reference resources https://docs.getsentry.com/on-premise/server/installation/
Requirements
- Linux Server
- PostgreSQL
- redis-server
- Python 2/3
- Nginx
step
Install dependency packages
sudo apt-get install python-setuptools python-pip python-dev libxslt1-dev libxml2-dev libz-dev libffi-dev libssl-dev libpq-dev libyaml-dev
install Sentry
pip install -U sentry==8.0.0rc2
To configure
vim sentry.conf.py
DATABASES = { 'default': { 'ENGINE': 'sentry.db.postgres', 'NAME': 'sentry', 'USER': 'postgres', 'PASSWORD': '123456', 'HOST': 'localhost', 'PORT': '5432', } }
EMAIL_HOST = 'smtp.exmail.qq.com' EMAIL_HOST_PASSWORD = 'HE*******' EMAIL_HOST_USER = '[email protected]' EMAIL_PORT = 25 EMAIL_USE_TLS = False
Set the configuration file path to the environment variable
export SENTRY_CONF=/home/hewx/workbench/sentry
Initialize database
sentry update
To configure Web Server
sudo apt-get install nginx-full sudo vim /etc/nginx/sites-enabled/default
location / { proxy_pass http://localhost:9000; proxy_redirect off;
proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }
start-up
start-up Wokers
sentry celery worker -B
start-up Web service
sentry start
example
PHP
Use browser access sentry, And create a project
Reference resources PHP Use instruction http://10.0.0.180/sentry/45183e54fa36/settings/install/php/
<?php
require_once "vendor/autoload.php";
$client = new Raven_Client('http://5d68caa5e36c4eaa8f7c0601a521fab6:[email protected]/3');
$error_handler = new Raven_ErrorHandler($client); $error_handler->registerExceptionHandler(); $error_handler->registerErrorHandler(); $error_handler->registerShutdownFunction();
$client->captureMessage(" An error has occurred here ");
$i = 1 / 0;
?>
Python
pip install raven
from raven import Client
client = Client('http://f1ba62aa87cb4fc1a36d9e4f96017e99:[email protected]/4')
try: 1 / 0 except ZeroDivisionError: client.captureException()
JavaScript
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sentry Test</title> </head> <body> <script src="https://cdn.ravenjs.com/2.0.1/raven.min.js"></script> <script> Raven.config('http://[email protected]/5').install()
try { doSomething(a[0]) } catch(e) { Raven.captureException(e) }
</script> </body> </html>
Android
https://github.com/joshdholtz/Sentry-Android/tree/android-studio-ify
import com.joshdholtz.sentry.Sentry;
public class MainActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
Sentry.init(this, "http://10.0.0.180", "http://340137fc1dc6443e99d9d02b8f1638d0:[email protected]/6"); Sentry.captureMessage("OMG this works woooo");
int a = 1 / 0; } ......
RuntimeException: Unable to start activity ComponentInfo{com.joshdholtz.sentrytesting/com.joshdholtz.sentryapp.MainActivity}: java.lang.ArithmeticException: divide by zero Module "android.app.ActivityThread", line 2189, in performLaunchActivity Module "android.app.ActivityThread", line 2238, in handleLaunchActivity Module "android.app.ActivityThread", line 138, in access$800 Module "android.app.ActivityThread$H", line 1201, in handleMessage Module "android.os.Handler", line 102, in dispatchMessage Module "android.os.Looper", line 136, in loop Module "android.app.ActivityThread", line 5016, in main Module "java.lang.reflect.Method", in invokeNative Module "java.lang.reflect.Method", line 515, in invoke Module "com.android.internal.os.ZygoteInit$MethodAndArgsCaller", line 792, in run Module "com.android.internal.os.ZygoteInit", line 608, in main Module "dalvik.system.NativeStart", in main
ArithmeticException: divide by zero Module "com.joshdholtz.sentryapp.MainActivity", line 20, in onCreate Module "android.app.Activity", line 5251, in performCreate Module "android.app.Instrumentation", line 1087, in callActivityOnCreate Module "android.app.ActivityThread", line 2153, in performLaunchActivity Module "android.app.ActivityThread", line 2238, in handleLaunchActivity Module "android.app.ActivityThread", line 138, in access$800 Module "android.app.ActivityThread$H", line 1201, in handleMessage Module "android.os.Handler", line 102, in dispatchMessage Module "android.os.Looper", line 136, in loop Module "android.app.ActivityThread", line 5016, in main Module "java.lang.reflect.Method", in invokeNative Module "java.lang.reflect.Method", line 515, in invoke Module "com.android.internal.os.ZygoteInit$MethodAndArgsCaller", line 792, in run Module "com.android.internal.os.ZygoteInit", line 608, in main Module "dalvik.system.NativeStart", in main
边栏推荐
- linux初始化mysql时报错 FATAL ERROR: Could not find my-default.cnf
- Vrrp+mstp configuration details [Huawei ENSP experiment]
- Js继承方法
- Larkapi access credentials overview
- Hcip --- LDP and MPLS Technology (detailed explanation)
- Use of tkmapper - super detailed
- 图片批处理|必备小技能
- [opencv] generate transparent PNG image
- [cloud computing] several mistakes that enterprises need to avoid after going to the cloud
- Analysis and recurrence of network security vulnerabilities
猜你喜欢

1w5字详细介绍分布式系统的那些技术方案

CSV文件存储

Basic syntax of jquey

JSON 文件存储

Bash shell interaction free

The cooperation between starfish OS and metabell is just the beginning

Image batch processing | necessary skills

Argocd Web UI loading is slow? A trick to teach you to solve

Shell programming specifications and variables

Quickly build a gateway service, dynamic routing and authentication process, and watch the second meeting (including the flow chart)
随机推荐
Data fabric, next air outlet?
Oracle SQL problems
Detailed explanation of the basic use of express, body parse and express art template modules (use, route, path matching, response method, managed static files, official website)
Learn to draw with nature communications -- complex violin drawing
Use of tkmapper - super detailed
49 opencv deep analysis profile
NPM and yarn use (official website, installation, command line, uploading your own package, detailed explanation of package version number, updating and uninstalling package, viewing all versions, equ
View the dimensions of the list
How can MySQL query judge whether multiple field values exist at the same time
Basic syntax of jquey
[soft test software evaluator] 2013 comprehensive knowledge over the years
Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]
Recycling of classes loaded by classloader
Flink window & time principle
1w5字详细介绍分布式系统的那些技术方案
[opencv] generate transparent PNG image
Three ways to create threads
VS2015使用dumpbin 查看库的导出函数符号
Service current limiting and fusing of micro service architecture Sentinel
Why setting application.targetframerate doesn't work