My ini configuration specifies:
log-date = %%Y-%%m-%%d %%H:%%M:%%S
logformat-strftime = true
When uWSGI logs non-request-related messages, it uses the specified date
format, e.g.
2016-08-22 00:00:04 - *** Starting uWSGI 2.0.13.1 (64bit) on [Mon Aug 22
00:00:04 2016] ***
I wanted uWSGI to use this format when logging HTTP requests too. Accomplishing
this was simply a matter of adding %(date) inside the "log-format" string. I
didn't see that documented anywhere on
http://uwsgi-docs.readthedocs.io/en/latest/LogFormat.html#functions so I
thought I'd share in case anyone else finds useful.
Another tip is that you can use e.g. %(var.HTTP_FOO) to log the value of the
"FOO" request header. The docs mention var.XXX where XXX is a request variable
like PATH_INFO, but I found it especially useful to discover this includes HTTP
headers.
One thing you can do with this if you have CloudFlare in front of your site is
to add %(var.HTTP_CF_IPCOUNTRY) and %(var.HTTP_CF_RAY) to log-format, so that
your logs capture the geoip and request ID headers that CloudFlare adds. I
assume you can do something similar if you use another CDN.
Hope this is helpful to someone.
Question: To keep things simpler on my server, I have uWSGI listening on port
8443 with packets from port 443 forwarding to it. Given that I'm adding
appropriate cache headers and have CloudFlare in front to absorb traffic, and
that I have uWSGI's "https2" and "static-map" functionality configured and
working fine, I saw no need to add something like NGINX in front of uWSGI to
handle HTTPS or static file serving.
Is a setup like this unusual or ill-advised for some reason? It's been working
well for me so far, but it's only been a few months of development/test
traffic; I have not yet put this behind production traffic.
In case relevant, I have uWSGI serving a fairly simple Flask app, am not
specifying number of threads or processes (uWSGI's defaults have been working
fine, and I've no reason to load test yet), and am running CPython 3.5 on the
$5/month DigitalOcean droplet (though can upgrade anytime as needed).
Thanks in advance for any feedback.
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi