Django StreamHandler日志在mod_wsgi安装程序中不工作

Django StreamHandler日志在mod_wsgi安装程序中不工作,django,logging,mod-wsgi,Django,Logging,Mod Wsgi,我试图让所有日志消息都转到标准apache错误日志,但我就是无法让它工作。如果我写入一个文件,这很好,但是apache日志完全不起作用。有什么建议吗?以下是我的相关配置: settings.py(代码片段) 虚拟主机配置 <VirtualHost *:80> SetEnv DJANGO_DEBUG True ServerName virtualimpact.userhome.test-env.net LogLevel debug ErrorLog

我试图让所有日志消息都转到标准apache错误日志,但我就是无法让它工作。如果我写入一个文件,这很好,但是apache日志完全不起作用。有什么建议吗?以下是我的相关配置:

settings.py(代码片段)


虚拟主机配置

<VirtualHost *:80>
    SetEnv DJANGO_DEBUG True

    ServerName virtualimpact.userhome.test-env.net

    LogLevel debug
    ErrorLog   "/home/developer/logs/developer-machine_error.log"
    CustomLog "/home/developer/logs/developer-machine_com_access.log" combined

    Alias /static/ /home/developer/htdocs/path/to/htdocs/static/

    <Directory /home/developer/htdocs/path/to/htdocs/static>
      Order deny,allow
      Allow from all
    </Directory>

    WSGIScriptAlias / /home/developer/htdocs/path/to/mod_wsgi/django.wsgi
</VirtualHost>

views.py(片段)

如果你需要更多的信息,请告诉我,这件事困扰了我一段时间,我对此束手无策

提前谢谢

编辑:另外,我使用的是Python 2.6.6和Django==1.4.3

编辑:它正在记录,但是到了错误的文件! 所以我不知道为什么之前没有检查,但结果表明,我写入stdout(或stderr)的任何内容都将进入/var/log/httpd/中的日志,而不是我专门为此虚拟主机配置的日志。我想知道这是否比Django更像是一个mod_wsgi问题,但我不能确定。我的mod_wsgi和vhost.conf文件正确吗


谢谢,

好的,这似乎是因为我在嵌入式模式下运行mod_wsgi,而不是作为守护进程。我一切换它,我的日志就开始出现在正确的位置。我们来看看情况如何,但到目前为止还不错

<VirtualHost *:80>
    SetEnv DJANGO_DEBUG True

    ServerName virtualimpact.userhome.test-env.net

    LogLevel debug
    ErrorLog   "/home/developer/logs/developer-machine_error.log"
    CustomLog "/home/developer/logs/developer-machine_com_access.log" combined

    Alias /static/ /home/developer/htdocs/path/to/htdocs/static/

    <Directory /home/developer/htdocs/path/to/htdocs/static>
      Order deny,allow
      Allow from all
    </Directory>

    WSGIScriptAlias / /home/developer/htdocs/path/to/mod_wsgi/django.wsgi
</VirtualHost>
import os, sys, site

workspace = os.path.abspath('%s/..' % os.path.dirname(__file__))
activate_this = os.path.abspath('%s/virtpy/bin/activate_this.py' % workspace)
execfile(activate_this, dict(__file__=activate_this))

sys.path.append(workspace)
sys.path.append('%s/htdocs' % workspace)

os.environ['DJANGO_SETTINGS_MODULE'] = 'htdocs.settings'
os.environ['PYTHON_EGG_CACHE'] = '%s/mod_wsgi/egg-cache' % workspace

import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()

def application(environ, start_response):
    os.environ['DJANGO_DEBUG'] = environ.get('DJANGO_DEBUG', 'False')
    return _application(environ, start_response)
import logging
logger = logging.getLogger('')
...

class AbstractsListView(BaseListView):
    def get_context_data(self, **kwargs):
        # none of the below calls write to the error log
        logger.debug('debug it')
        logger.info('info it')
        import sys
        sys.stderr.write('asdfasdf')
        ...