Skip to content Skip to sidebar Skip to footer

No Exception Log Output In Excepiton.log File In Pyramid Project With Plugin Pyramid_exclog Under Uwsgi

I use uwsgi to deploy my pyramid project. and also use pyramid_exclog to catch exception log which is expected to logto the file exception.log . But all the log info(include the ex

Solution 1:

I ran into the same problem. I've tried the --ini-paste-logged option, but that requires Paste. I'm running under Python 3.3 and Paste hasn't been updated for Python 3, so that wasn't going to work for me.

What I came up with was to create my own WSGI application file like so (file named production.wsgi):

import configparser
import logging.config

from myapp import main

ini_path = 'production.ini'# Set up logging
logging.config.fileConfig(ini_path)

# Parse config and create WSGI app
config = configparser.ConfigParser()
config.read(ini_path)

# First argument is default config values, second argument are the settings# from the app:main section# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/startup.html
application = main(config['DEFAULT'], **config['app:main'])

Then in my production.ini file I have the following [uwsgi] section:

[uwsgi]wsgi-file = %d/production.wsgi
chdir = %d
http-socket = :29999enable-threads = truemaster = trueprocesses = 1

Instead of starting it with --ini-paste or --ini-paste-logged, I just start it with --ini:

/usr/bin/uwsgi --ini /usr/local/myapp/production.ini

(uWSGI is actually installed into my app's virtual environment.)

Solution 2:

pyramid_exclog uses the standard python logging module. Thus you need to ensure that uwsgi is parsing logging configuration from your ini when running your application. I think this involves invoking your app with --ini-paste-logged or some such under uWSGI. Also, ensure you actually setup logging as mentioned in the pyramid_exclog documentation.

Solution 3:

Here is how I do it. Found this on irc log

First, make sure you set it up properly like described here

Then set the logging manually in your app

from pyramid.paster import setup_logging

# somewhere in your main app
setup_logging('your-settings.ini')

I do not know if there is side effects doing this but so far it works

Post a Comment for "No Exception Log Output In Excepiton.log File In Pyramid Project With Plugin Pyramid_exclog Under Uwsgi"