uWSGI logging issues with Pyramid

478 views
Skip to first unread message

Zsolt Ero

unread,
Jan 19, 2017, 10:08:49 AM1/19/17
to pylons-discuss

I believe this is uWSGI specific, and might even be a bug in uWSGI, but since many people are using uWSGI with Pyramid here, I'd be interested to know how did you solve it.


I've migrated a project from Gunicorn to uWSGI. My problem is that my previously set-up file-based logging is all bypassed / redirected now with custom format discarded.


Previously it wrote to pyramid.log (and any other specific logs I had). Now, after converting to uWSGI:

  • pyramid.log file is created but empty
  • every log is redirected to uwsgi.log, with all custom formatters discarded.

How can I make uWSGI not overwrite the whole, carefully set-up Python logging system, and only output it's own log to uwsgi.log?


my uwsgi.ini:

[uwsgi]
paste = config:/home/app/web/app_web/production.ini
http-socket = :5000
uid = app
gid = app

master = true
processes = 16
enable-threads = true
harakiri = 60
harakiri-verbose = true
single-interpreter = true

die-on-term = true
vacuum = true

disable-logging = true
logto2 = /shared/logs/CURRENT/app/uwsgi.log

stats = /home/app/uwsgi_stats.socket


My logging setup is as follows:

[loggers]
keys = root, app_web, sqlalchemy

[handlers]
keys = filelog_pyramid

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = filelog_pyramid

[logger_app_web]
level = WARN
handlers =
qualname = app_web

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[handler_filelog_pyramid]
class = FileHandler
args = ('/shared/logs/CURRENT/app/pyramid.log','a')
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s

Bert JW Regeer

unread,
Jan 19, 2017, 12:16:50 PM1/19/17
to pylons-...@googlegroups.com
Are you setting up logging explicitly?

uWSGI doesn’t automatically set up Python logging when you provide it a paster ini file, how are you starting uWSGI?

Bert

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/6c07825a-34f5-4542-b4c2-bf7759eda509%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zsolt Ero

unread,
Jan 19, 2017, 12:18:36 PM1/19/17
to pylons-...@googlegroups.com
I'm just simply calling uwsgi uwsgi.ini and and it has the logto line in there.
> You received this message because you are subscribed to a topic in the
> Google Groups "pylons-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pylons-discuss/CO5z2MD3iA0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> pylons-discus...@googlegroups.com.
> To post to this group, send email to pylons-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/8DBCF3A1-E4AF-44A2-AD98-0E7A5381DC16%400x58.com.

Bert JW Regeer

unread,
Jan 19, 2017, 12:42:26 PM1/19/17
to pylons-...@googlegroups.com
You’ll need something like:

paste-logger = %p
As well for uWSGI to automatically pick up your logger configuration from .ini file: http://uwsgi-docs.readthedocs.io/en/latest/Options.html?highlight=paste-logger#paste-logger

uWSGI doesn’t automatically pick up your fileConfig logging otherwise.

(Basically unless you explicitly call fileConfig for your .ini right now uWSGI doesn’t do anything with your logging handlers/information)


Zsolt Ero

unread,
Jan 19, 2017, 12:57:02 PM1/19/17
to pylons-...@googlegroups.com
Thanks! So I added "paste-logger = true" and then I got a warning saying:

ImportError: No module named script.util.logging_config

Which I found out on SO can be fixed by installing pastescript. So the
combination of paste-logger = true + pastescript in requirements seems
to have fixed it!
> https://groups.google.com/d/msgid/pylons-discuss/2D18C5AC-B027-4DF2-B298-AB9F5480449A%400x58.com.

Jonathan Vanasco

unread,
Jan 20, 2017, 11:56:14 AM1/20/17
to pylons-discuss
I think the command you want in uwsgi is `ini-paste-logged` instead of `paste`



Zsolt Ero

unread,
Jan 20, 2017, 12:13:07 PM1/20/17
to pylons-...@googlegroups.com
I was thinking of that as well, but it implies using the same ini file, which I'd like to keep separate.


On 2017. Jan 20., Fri at 17:56, Jonathan Vanasco <jvan...@gmail.com> wrote:
I think the command you want in uwsgi is `ini-paste-logged` instead of `paste`











--


You received this message because you are subscribed to a topic in the Google Groups "pylons-discuss" group.


To unsubscribe from this topic, visit https://groups.google.com/d/topic/pylons-discuss/CO5z2MD3iA0/unsubscribe.


To unsubscribe from this group and all its topics, send an email to pylons-discus...@googlegroups.com.


To post to this group, send email to pylons-...@googlegroups.com.


Jonathan Vanasco

unread,
Jan 20, 2017, 6:10:11 PM1/20/17
to pylons-discuss


On Friday, January 20, 2017 at 12:13:07 PM UTC-5, Zsolt Ero wrote:
I was thinking of that as well, but it implies using the same ini file, which I'd like to keep separate.

yes, i believe it does.

i set all my uwgsi options via commandline flags, so ini-paste-logged works for me.

it might sound counterproductive, but i use supervisorctl to manage the process -- so instead of having different uwsgi configuration files for variations on deployment, I have different config files for supervisor.

 
Reply all
Reply to author
Forward
0 new messages