Access log format#
AccessLogMiddleware writes one line per HTTP request and one line per websocket session to the ploneasgi.access logger, at level INFO.
PLONE_ACCESS_LOG enables it.
Format#
The default format is Apache combined, plus two timings and a note:
%(client)s - %(user)s [%(time)s] "%(method)s %(path)s %(protocol)s" %(status)s %(bytes)s %(duration)s %(ttfb)s "%(referer)s" "%(user_agent)s"%(note)s
An example line:
127.0.0.1 - - [26/Oct/2026:11:28:59 -0300] "GET /Plone HTTP/1.1" 200 8790 0.733 0.732 "-" "curl/8.7.1"
Fields#
Field |
HTTP request |
Websocket session |
|---|---|---|
|
Socket address of the client. With |
Same. |
|
The |
Same. |
|
Local time when the line is written, Apache format. |
Same. |
|
Request method. |
|
|
Path as it arrived, rewrite included, with the query string. |
Same. |
|
|
Same. |
|
Response status, or |
The close code, from whichever side closed. With no close code recorded: |
|
Body bytes the application emitted. |
|
|
Seconds from arrival to the final body event. |
Seconds from arrival to close. |
|
Seconds from arrival to the response start event. |
|
|
|
Same. |
|
|
Same. |
|
See Notes. |
|
Every string field is escaped as Apache escapes it: " becomes \", \ becomes \\, and each control character becomes \xhh.
Notes#
Note |
Meaning |
|---|---|
(none) |
The final body event was sent. |
|
No response started. |
|
The client disconnected while the body was streaming, and the adapter stopped. |
|
The application stopped emitting before its final body event, typically an exception mid-stream. |
Important
bytes is an upper bound on what the client received.
Bytes already handed to the server may never have left the socket buffer.
Behind a proxy, the proxy's log is authoritative on delivery.
Constructor options#
Option |
Default |
Meaning |
|---|---|---|
|
|
Percent-style format string over the fields above. |
|
|
Read |
|
|
Level to log at. |
|
|
Logger to write to. |
create_app() adds the middleware with its defaults.
To change an option, leave PLONE_ACCESS_LOG off and pass the middleware yourself in middleware.