We are running a Django server and using Sentry to capture exceptions. When we configure Sentry we add RAVEN_CONFIG
our different settings.py
files:
我们正在运行Django服务器并使用Sentry捕获异常。当我们配置Sentry时,我们将不同的settings.py文件添加到RAVEN_CONFIG:
INSTALLED_APPS = (
'raven.contrib.django.raven_compat'
)
RAVEN_CONFIG = {
'dsn': 'https://*****@app.getsentry.com/PORT_NUMBER',
}
We read here that we can just use an empty string DSN
property. Though when we run python manage.py raven test
as depicted here we get:
我们在这里读到我们可以使用空字符串DSN属性。虽然当我们运行python manage.py raven test时,我们得到:
raven.exceptions.InvalidDsn: Unsupported Sentry DSN scheme: ()
The best solution would be that we could always use a Raven client and the settings file would define whether exceptions are sent or not.
最好的解决方案是我们可以始终使用Raven客户端,设置文件将定义是否发送异常。
Another requirement is that we would like to use the Client
module and capture exceptions. For this we have to set some DSN
value:
另一个要求是我们希望使用Client模块并捕获异常。为此,我们必须设置一些DSN值:
from raven import Client
client = Client('https://<key>:<secret>@app.getsentry.com/<project>')
So not setting a DSN
value isn't possible
因此,不能设置DSN值
2 个解决方案
#1
7
Documentation didn't say you have to set DSN
value, there's just an example how to set it.
文档没有说你必须设置DSN值,这里只是一个如何设置它的例子。
In [1]: from raven import Client
In [2]: client = Client()
Raven is not configured (logging is disabled). Please see the documentation for more information.
In [3]: client.captureMessage('hello') # it's a noop - no error, no capture.
It's important to note that you should pass None
(or nothing at all) as DSN
parameter and not empty string, otherwise it raises InvalidDsn: Unsupported Sentry DSN scheme
.
重要的是要注意你应该传递None(或根本不传递)作为DSN参数而不是空字符串,否则它会引发InvalidDsn:不支持的Sentry DSN方案。
Also, if you don't like that Raven is not configured (logging is disabled)...
in your logs, you can mute it like so:
此外,如果您不喜欢未配置Raven(日志已禁用)...在日志中,您可以将其静音:
>>> import logging
>>> logging.getLogger('raven').setLevel(logging.WARNING)
#2
13
We read here that we can just use an empty string DSN property.
我们在这里读到我们可以使用空字符串DSN属性。
You should not be setting DSN
to an empty string, but instead in your development settings configuration don't specify the DSN
setting in the first place:
您不应将DSN设置为空字符串,而是在开发设置配置中首先不指定DSN设置:
RAVEN_CONFIG = {}
#1
7
Documentation didn't say you have to set DSN
value, there's just an example how to set it.
文档没有说你必须设置DSN值,这里只是一个如何设置它的例子。
In [1]: from raven import Client
In [2]: client = Client()
Raven is not configured (logging is disabled). Please see the documentation for more information.
In [3]: client.captureMessage('hello') # it's a noop - no error, no capture.
It's important to note that you should pass None
(or nothing at all) as DSN
parameter and not empty string, otherwise it raises InvalidDsn: Unsupported Sentry DSN scheme
.
重要的是要注意你应该传递None(或根本不传递)作为DSN参数而不是空字符串,否则它会引发InvalidDsn:不支持的Sentry DSN方案。
Also, if you don't like that Raven is not configured (logging is disabled)...
in your logs, you can mute it like so:
此外,如果您不喜欢未配置Raven(日志已禁用)...在日志中,您可以将其静音:
>>> import logging
>>> logging.getLogger('raven').setLevel(logging.WARNING)
#2
13
We read here that we can just use an empty string DSN property.
我们在这里读到我们可以使用空字符串DSN属性。
You should not be setting DSN
to an empty string, but instead in your development settings configuration don't specify the DSN
setting in the first place:
您不应将DSN设置为空字符串,而是在开发设置配置中首先不指定DSN设置:
RAVEN_CONFIG = {}