Skip to content

Commit ff2cef0

Browse files
committed
Tweak the default acccess log format
Make sure we've got the most important information like remote addr, request status line, response code, response size, user agent and request processing time, e.g: [10/Jan/2018:21:04:46 +0000] 127.0.0.1 "GET /snippets/42/raw HTTP/1.1" 200 154 "curl/7.54.0" 0.100991 Note, that for production deploys behind a reverse-proxy this format might be changed to use the HTTP headers like X-Real-IP or X-Forwarded-For, if needed.
1 parent f757b4b commit ff2cef0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

xsnippet/web_backend/__main__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@
1212

1313
# create an app instance and listen forever
1414
app = create_app(conf)
15-
aiohttp.web.run_app(app, host=conf.LISTEN_HOST, port=conf.LISTEN_PORT)
15+
aiohttp.web.run_app(
16+
app,
17+
host=conf.LISTEN_HOST,
18+
port=conf.LISTEN_PORT,
19+
access_log_format=conf.ACCESS_LOG_FORMAT
20+
)

xsnippet/web_backend/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55

66
LISTEN_HOST = os.environ.get('XSNIPPET_WEB_PROXY_HOST', '0.0.0.0')
77
LISTEN_PORT = os.environ.get('XSNIPPET_WEB_PROXY_PORT', 5000)
8+
9+
ACCESS_LOG_FORMAT = '%t %a "%r" %s %b "%{User-Agent}i" %Tf'

0 commit comments

Comments
 (0)