2016-04-06 9 views
1

Ich habe ein Kolben-Projekt mit Protokollierung von einer Konfigurationsdatei eingerichtet. Dies funktioniert wie gewünscht, wenn lokal ausgeführt, aber wenn ich es unter Apache wsgi ausführen, werden alle Protokollmeldungen (nicht nur Fehler) in die Datei error.log geschrieben, die auch im vhost eingerichtet ist.Alle Protokolle in Apache Fehlerprotokoll dupliziert

Nach einigem googeln fand ich this issue, die ich dachte, könnte verwandt sein und versuchte, app.logger_name zu setzen und app.logger zu nennen, aber ich habe immer noch das gleiche Problem.

config/logging.yaml: pastebin

Vhost:

<VirtualHost *:80> 
     ServerName myapp.com 

     WSGIDaemonProcess myapp home=/var/www/vhosts/myapp/httpdocs 
     WSGIScriptAlias//var/www/vhosts/myapp/httpdocs/myapp.wsgi 

     <Directory /var/www/vhosts/myapp/httpdocs> 
       WSGIProcessGroup myapp 
       WSGIApplicationGroup %{GLOBAL} 
       Order deny,allow 
       Allow from all 
     </Directory> 

     ErrorLog /var/www/vhosts/myapp/logs/error.log 
     CustomLog /var/www/vhosts/myapp/logs/access.log combined 
</VirtualHost> 

myapp.wsgi:

activate_this = '/var/www/vhosts/myapp/httpdocs/env/bin/activate_this.py' 
execfile(activate_this, dict(__file__=activate_this)) 

import sys 
sys.path.insert(0, '/var/www/vhosts/myapp/httpdocs') 

from run_web import app as application 

run_web.py:

import init 
import logging 
from web import app, api 

init.add_to_syspath() 

init.logging_conf() 

# Flask removes all log handlers so our logs are written to the error log as well. 
app.logger_name = "nowhere" 
app.logger 

logger = logging.getLogger('run_web') 

logger.info('Starting web') 

api.init() 

if __name__ == '__main__': 
    logger.info('Flask running in debug mode') 
    app.debug = True 
    app.run() 

init.logging_conf ():

def logging_conf(): 
    with open('conf/logging.yaml', 'r') as yaml_file: 
     logging_config = yaml.load(yaml_file) 

    dictConfig(logging_config) 

Antwort

Verwandte Themen