Daphne 没有记录错误

Daphne not logging errors

我有以下系统配置

[Service]
WorkingDirectory=/srv/www/project_a/project_a/
Environment=JSON_SETTINGS=/srv/www/project_a/project_a.json
ExecStart=/srv/www/project_a/bin/daphne -b 0.0.0.0 -p 8000 project_a.asgi:channel_layer
Restart=always
KillSignal=SIGTERM
NotifyAccess=all
StandardOut=file:/tmp/daphne-access.log
StandardError=file:/tmp/daphne-error.log

但是daphne-access.log和daphone-error.log文件都是空的,我以为daphne的默认注销会输出到stdout?

尝试过:--access-log=/tmp/daphne-access.log 对访问日志有效,但不知道发生 django 错误时从哪里获取。

对于 Django 错误,您需要定义 Django 日志。请参阅文档以获取更多信息。

https://docs.djangoproject.com/en/2.2/topics/logging/

只需将以下内容添加到您的 LOGGING['loggers'] 设置中:

'daphne': {
    'handlers': [
        'console',
    ],
    'level': 'DEBUG'
},