【问题标题】:Azure web service and Django logAzure Web 服务和 Django 日志
【发布时间】:2017-03-30 10:02:31
【问题描述】:

我在写日志时遇到了一些令人困惑的问题......

下面是我的setting.py:

DEBUG = True
TEMPLATE_DEBUG = DEBUG
.....
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'logfile': {
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.getenv('LOGFILE', 'django.log')
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        'django': {
            'handlers': ['logfile'],
            'level': 'INFO',
            'propagate': False,
        }
    }
}

** 我想将所有 INFO 消息传递给 django.log。

当我在 localhost 测试运行服务器时,它会正确写入 django.log。

在我发布到 Azure Web 应用服务并设置“应用程序设置”=>“应用程序设置”后,添加新路径 LOGFILE D:\home\site\wwwroot\logfiles\django.log。 enter image description here

我向我的应用服务发送了一些请求,然后登录 DebugConsole 以查看 D:\home\site\wwwroot\logfiles\django.log 文件。 enter image description here

此日志文件(django.log)中没有任何内容,我尝试在 DebugConsole 修改它,它会出现 ERROR 409 confict: Could not write to local resource 'D:\home\site\wwwroot\ logfiles\django.log' 由于错误“进程无法访问文件 'D:\home\site\wwwroot\logfiles\django.log' 因为它正被另一个进程使用。”。

似乎 Django 无法在 django.log 中写入任何内容或权限问题?我能怎么做? 有人可以帮忙解决这个问题吗?

【问题讨论】:

标签: python django azure logging django-models


【解决方案1】:

我有类似的问题。我在这里找到了解决方案: http://azaleasays.com/2014/05/01/django-logging-with-rotatingfilehandler-error/

简而言之:启动服务器: python manage.py runserver --noreload

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-13
    • 1970-01-01
    相关资源
    最近更新 更多