在uwsgi下,金字塔项目带有插件pyramid_exclog的excepiton.log文件中没有异常日志输出 [英] No exception log output in excepiton.log file in pyramid project with plugin pyramid_exclog under uwsgi

查看:82
本文介绍了在uwsgi下,金字塔项目带有插件pyramid_exclog的excepiton.log文件中没有异常日志输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用uwsgi部署我的金字塔项目.并且还使用pyramid_exclog捕获异常日志,该日志有望记录到文件exception.log中.但是所有日志信息(包括异常日志)都输出到文件"project.log",该文件在[uwsgi]部分的文件production.ini

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

我需要您的帮助,以将异常信息输出到exception.log文件而不是project.log文件中 我使用"pserve"命令启动我的项目,一切正常. 那么如何在uwsgi下部署pyramid_exclog.

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.

推荐答案

我遇到了同样的问题.我已经尝试过--ini-paste-logged选项,但这需要粘贴.我在Python 3.3下运行,并且Paste尚未针对Python 3进行更新,所以这对我来说行不通.

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.

我想到的是像这样创建自己的WSGI应用程序文件(名为production.wsgi的文件):

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'])

然后在我的production.ini文件中,有以下[uwsgi]部分:

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

我不是以--ini-paste--ini-paste-logged开头,而是以--ini开头:

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实际上已安装到我的应用程序的虚拟环境中.)

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

这篇关于在uwsgi下,金字塔项目带有插件pyramid_exclog的excepiton.log文件中没有异常日志输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆