简体   繁体   中英

Force uwsgi to write to log file only requests

I want uwsgi server to log only requests, skipping any uwsgi startup related entries etc. Below is an example of content pulled out of log file. Is there a setting that I'm missing?

*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x193c890
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145520 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 6 seconds on interpreter 0x193c890 pid: 23761 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 23761)
spawned uWSGI worker 1 (pid: 23763, cores: 1)
192.168.33.1 - - [07/Apr/2015:22:02:17 +0000] "GET / HTTP/1.1" 200 4611 "http://192.168.33.10/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"
192.168.33.1 - - [07/Apr/2015:22:02:17 +0000] "GET /static/bower_components/bootstrap-multiselect/dist/css/bootstrap-multiselect.css HTTP/1.1" 304 303 "http://192.168.33.10/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"
192.168.33.1 - - [07/Apr/2015:22:02:17 +0000] "GET /static/bower_components/bootstrap/dist/css/bootstrap.css HTTP/1.1" 304 305 "http://192.168.33.10/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"
192.168.33.1 - - [07/Apr/2015:22:02:17 +0000] "GET /static/css/bootstrap.css HTTP/1.1" 304 305 "http://192.168.33.10/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"
192.168.33.1 - - [07/Apr/2015:22:02:17 +0000] "GET /static/css/style.css HTTP/1.1" 304 303 "http://192.168.33.10/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"

Solution was to use req-logger instead of logto (which will catch all loggers in your application). In addition to make your log format apache style, use log-format value below.

[uwsgi]
req-logger = file:/some_base_path/logs/access.log
log-format = %(addr) - %(user) [%(ltime)] "%(method) %(uri) %(proto)" %(status) %(size) "%(referer)" "%(uagent)"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM