To have logging(like one has under paster) under mod_wsgi one has to initialize logging on the mod_wsgi's app.wsgi.
Let's suposed you have your app.wsgi inside the project's dir, where you also find setup.py.
Here's an example /path/to/project/dir/app.wsgi:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import os, sys from paste.script.util.logging_config import fileConfig BASEDIR = os.path.dirname(__file__) INIFILE = os.path.join(BASEDIR, 'production.ini') sys.path.append(BASEDIR) os.environ['PYTHON_EGG_CACHE'] = '/var/tmp' fileConfig( INIFILE ) from paste.deploy import loadapp application = loadapp('config:%s' % INIFILE)) |
Now you have to setup the logger handlers for your /path/to/project/dir/production.ini:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Logging configuration [loggers] keys = root, <app_name> [handlers] keys = file [formatters] keys = generic [logger_root] level = ERROR handlers = file [logger_<app_name>] level = DEBUG handlers = file qualname = <app_name> [handler_file] class = handlers.RotatingFileHandler args = ('/path/to/project/dir/app.log', 'a', 2048, 3) |
Please refer to the python documentation regarding the rotating file handler arguments.
Comments (2)
Oct 02, 2008
Junya HAYASHI says:
I failed to use pylons.log.WSGIErrorsHandler. My apache's error_log is following...I failed to use pylons.log.WSGIErrorsHandler. My apache's error_log is following.
Some one succeeds using WSGIErrorsHandler with pylons and mod_wsgi ?
Sep 20, 2010
Greg Lavallee says:
This setup worked for me. Thanks!This setup worked for me. Thanks!