Il 23/08/2016 05:33, [email protected] ha scritto:
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.

Feel free to add these tips to uwsgi documentation (https://github.com/unbit/uwsgi-docs) or generally improve it :)

--
Riccardo Magliocchetti
@rmistaken

http://menodizero.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to