Search code examples
pythonloggingpyramiduwsgi

Pyramid uWSGI logging in daemon mode is not working


I've been trying multiple things on this one, but with no success. I want to save log to file (SqlAlchemy logs, app debug logs, stack traces on errors, etc.).

I'm starting uwsgi with the following command: uwsgi --ini-paste-logged myapp.ini

And here is the content of the ini file (where apiservice is my pakage)

[loggers]
keys = root, apiservice, sqlalchemy

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[logger_apiservice]
level = DEBUG
handlers =
qualname = apiservice

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

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

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

[uwsgi]
socket = /tmp/myapp-uwsgi.sock
virtualenv = /var/www/myapp/env
pidfile = ./uwsgi.pid
daemonize = ./uwsgi.log
master = true
processes = 4

The uwsgi.log contains only request log, without any actual logging data.

I've tried with INI options like:

  • paste: config:%p
  • paste-logger: %p
  • logto: file

Nothing seem to work.


Solution

  • Apparently, the uwsgi config section was fine. After closer look at the uwsgi.log, even though the server was launched and running successfully, you could see an error:

    ImportError: No module named script.util.logging_config
    

    I've installed following packages to solve my problems:

    pip install pastescript
    pip install pastedeploy