Latest Version: 0.9.6.2
  Dashboard > Pylons Cookbook > ... > Deployment > Logging under mod_wsgi
  Pylons Cookbook Log In | Sign Up   View a printable version of the current page.  
  Logging under mod_wsgi
Added by Pedro Algarvio, aka, s0undt3ch, last edited by Pedro Algarvio, aka, s0undt3ch on Dec 27, 2007
Labels: 
(None)

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.

Site running on a free Atlassian Confluence Open Source Project License granted to Pylons. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.3.3 Build:#645 Feb 13, 2007) - Bug/feature request - Contact Administrators
Top