【问题标题】:Logging without exclusive locks on Windows在 Windows 上不使用独占锁进行日志记录
【发布时间】:2013-07-28 15:58:43
【问题描述】:

根据Python's documentation,在Windows下“日志记录会打开具有排他锁的文件”。

其实在 Django 中,有这样的配置:

'handlers': {
    'logfile': {
        'level':'DEBUG',
        'class':'logging.handlers.RotatingFileHandler',
        'filename': 'myapp.log',
        'maxBytes': 1024 * 1024,
        'backupCount': 9,
        'formatter': 'standard',
    },
},

当应用程序在 Windows Azure 网站上执行时(在 IIS + WSGI 下),在 Django 应用程序停止之前,任何其他应用程序都无法读取日志文件。

有没有办法在这种环境(Windows Server、IIS、WSGI)下登录文件而不用独占模式打开文件?

【问题讨论】:

    标签: python django logging azure


    【解决方案1】:

    您可以根据需要自行打开文件,并将生成的流传递给StreamHandler

    【讨论】:

      猜你喜欢
      • 2013-07-14
      • 1970-01-01
      • 2012-01-31
      • 1970-01-01
      • 2014-12-24
      • 1970-01-01
      • 1970-01-01
      • 2012-05-11
      • 2011-03-01
      相关资源
      最近更新 更多