【问题标题】:Daphne not logging errors达芙妮没有记录错误
【发布时间】:2019-04-02 21:56:56
【问题描述】:

我有以下 systemd 配置

[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 的默认注销是输出到标准输出?

尝试过:--access-log=/tmp/daphne-access.log 适用于访问日志,但不知道在发生 django 错误时从何处获取。

【问题讨论】:

    标签: daphne


    【解决方案1】:

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

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

    【讨论】:

    • 请记住,这将记录一切,不适合生产。对于 Prod,将级别设置为警告或错误。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-01
      • 2020-03-18
      • 2019-07-04
      • 1970-01-01
      • 2019-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多