17

I have just installed my first uWSGI server on EC2 Ubuntu 14.04 LTS, using the following configuration:

[uwsgi]
http-socket    = :9001
plugin    = python
wsgi-file = foo.wsgi
chdir = /home/bar
process   = 3

The uWSGI container works fine, but has no logging. Following the manual, I've added the following:

logger = file:/tmp/errlog

But restarting (using sudo service uwsgi restart) did not work - the server would not start with this configuration.

Any idea what's missing from my ini configuration?

Adam Matan
  • 128,757
  • 147
  • 397
  • 562

2 Answers2

25

The "common" syntax is "logto = file".

The logger option is used for advanced plugins, if you want to use the 'file' one you have to load the logfile plugin (like you load the python one). But honestly if you only want to log to a file, logto will be more than enough

roberto
  • 12,723
  • 44
  • 30
  • 1
    +1 Thanks. I added `logto = /tmp/errlog`, and restarted the server. The server works OK, but no log file is created. – Adam Matan Jun 02 '14 at 05:11
  • 1
    be sure to shutdown and completely start over the instance. reloading will not reset the logging subsystem – roberto Jun 02 '14 at 08:40
  • 2
    **logfile** plugin is need when you want to do log-route, you can add oneline to you config file:`plugin = logfile`, all suppor plugin may be found under */usr/lib/uwsgi/plugins* . – diabloneo Dec 11 '14 at 07:05
  • This just does not work for me. Running uwsgi version 2.0.17.1 for nginix within a python virtual environment. What I don't understand is why there is not a default log file. If uwsgi fails default is not to report it anywhere... I guess facebook being down would not worry anyone ;). The module in apache works so much better. – MagicLAMP Jan 31 '19 at 04:17
  • In latest documentation there is only --logto as command but not logto as a config in ini file rather they mentioned ``req-logger`` and `logger`. which also didnot work for me but after giving permission with `chown` as per @MagicLAMP answer, it works now – r2_d2 Apr 11 '22 at 12:03
13

The accepted answer did not work for me (possibly because it is 4 years old). Nginx running uwsgi 2.0.17.1 in a virtual env with circus controlling the workers. This did work though:

req-logger = file:/var/log/uwsgi/app/cart-req.log
logger = file:/var/log/uwsgi/app/cart-err.log

Not sure if it was necessary, but I

$ chown -R www-data:www-data /var/log/uwsgi/app

ref: https://uwsgi-docs.readthedocs.io/en/latest/Logging.html

as uwsgi runs as www-data

Jannie Theunissen
  • 28,256
  • 21
  • 100
  • 127
MagicLAMP
  • 1,032
  • 11
  • 26
  • 1
    M: `logto` only log start stdout/stderr, but when use daemonize2, `req-logger and logger ` take effect. – Cheney Apr 21 '19 at 15:14
  • 2
    You probably meant `chown` instead of `chmod`. Other than that, I tried this approach and although the config is accepted, I don't see the logs being written. I restarted `uwsgi` with `sudo service uwsgi restart` but that clearly is not enough? – Pankrates Oct 04 '21 at 08:15