88260

No exception log output in excepiton.log file in pyramid project with plugin pyramid_exclog under uw

Question:

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 exception log) was output to the file 'project.log' which was setted in the section of [uwsgi], file production.ini

[uwsgi] logto = /var/log/project.log

I need your help to make exception info output to the file of exception.log instead of project.log I use the 'pserve' command to start up my project, everything works well. So how to deploy the pyramid_exclog under uwsgi.

Answer1:

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 = :29999 enable-threads = true master = true processes = 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.)

Answer2:

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.

Answer3:

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

First, make sure you set it up properly like described <a href="http://docs.pylonsproject.org/projects/pyramid_exclog/en/latest/index.html" rel="nofollow">here</a>

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

Recommend

  • Wagtail: Deployment Issue - KeyError 'request' on /admin
  • Flask at first run: Do not use the development server in a production environment
  • Django Celery Scheduling a manage.py command
  • how to make apache run pyc file (python compiled file)
  • Switch off case sensitive URLs in Google App Engine
  • gevent fails to install in a python virtual environment on OS X Capitan
  • Alternative for django.db.close_connection()
  • Google App Engine - SSL InsecurePlatformWarning
  • Is there a way to choose which files are displayed to the user via the standard OPENFILE dialogs?
  • Emacs lua-mode issue: (void-function interactively-called-p)
  • Want to understand iframe breakout code
  • python: forcing relative imports to search from script file
  • What does “t” refer to in this SQL?
  • CERN ROOT exporting data to plain text
  • Run multiple queries from 1 SQL file showing result in multiple tables
  • Firefox Extension - Monitor refresh and change of tab
  • Django simple Captcha “No module named fields” error
  • How do I access an unhandled exception in an MVC Error view?
  • Xcode 4 NSLog Macro link in Xcode 3
  • Why does access(2) check for real and not effective UID?
  • Google Custom Search with transparent background
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • vba code to select only visible cells in specific column except heading
  • Do create extension work in single-user mode in postgres?
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • Python: how to group similar lists together in a list of lists?
  • How to include full .NET prerequisite for Wix Burn installer
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • Is it possible to post an object from jquery to bottle.py?
  • Does armcc optimizes non-volatile variables with -O0?
  • Busy indicator not showing up in wpf window [duplicate]
  • To Get the radio button value in ruby on rails
  • How to load view controller without button in storyboard?