Production request logger middleware.
This uses the Apache logging format, and takes IP addresses for clients from the socket (see IPAddrSource for more information). It logs to stdout.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulewai-extra-3.1.16Haskell2010
Production request logger middleware.
This uses the Apache logging format, and takes IP addresses for clients from the socket (see IPAddrSource for more information). It logs to stdout.
RequestLoggerSettings is an instance of Default. See Data.Default for more information.
outputFormat, autoFlush, and destination are record fields
for the record type RequestLoggerSettings, so they can be used to
modify settings values using record syntax.
Default RequestLoggerSettingsDefined in wai-extra-3.1.16 · Network.Wai.Middleware.RequestLoggerDefault value: Detailed True.
Only applies when using the Handle constructor for destination.
Default value: True.
Default: Handle stdout.
The logging format.
Settings for the ApacheWithSettings OutputFormat. This is purposely kept as an abstract data type so that new settings can be added without breaking backwards compatibility. In order to create an ApacheSettings value, use defaultApacheSettings and the various 'setApache' functions to modify individual fields. For example:
setApacheIPAddrSource FromHeader defaultApacheSettingsWhere to take IP addresses for clients from. See IPAddrSource for more information.
Default value: FromSocket
Function that allows you to filter which requests are logged, based on the request and response
Default: log all requests
Function that allows you to get the current user from the request, which will then be added in the log.
Default: return no user
Settings for the Detailed OutputFormat.
mModifyParams allows you to pass a function to hide confidential information (such as passwords) from the logs. If result is Nothing, then the parameter is hidden. For example: > myformat = Detailed True (Just hidePasswords) > where hidePasswords p@(k,v) = if k = "password" then (k, "***REDACTED***") else p
mFilterRequests allows you to filter which requests are logged, based on the request and response.
DetailedSettingsuseColors :: BoolmModifyParams :: Maybe (Param -> Maybe Param)mFilterRequests :: Maybe (Request -> Response -> Bool)mPrelogRequests :: BoolDefault DetailedSettingsDefined in wai-extra-3.1.16 · Network.Wai.Middleware.RequestLoggertype OutputFormatterWithDetails = ZonedDate -> Request -> Status -> Maybe Integer -> NominalDiffTime -> [ByteString] -> Builder -> LogStrtype OutputFormatterWithDetailsAndHeaders = ZonedDate -> Request -> Status -> Maybe Integer -> NominalDiffTime -> [ByteString] -> Builder -> [Header] -> LogStrSame as OutputFormatterWithDetails but with response headers included
This is useful if you wish to include arbitrary application data in your logs, e.g., an authenticated user ID, which you would set in a response header in your application and retrieve in the log formatter.
Source from which the IP source address of the client is obtained.
FromSocketFrom the peer address of the HTTP connection.
FromHeaderFrom X-Real-IP or X-Forwarded-For in the HTTP header.
This picks either X-Real-IP or X-Forwarded-For depending on which of these
headers comes first in the ordered list of request headers.
If the X-Forwarded-For header is picked, the value will be assumed to be a
comma-separated list of IP addresses. The value will be parsed, and the
left-most IP address will be used (which is mostly likely to be the actual
client IP address).
FromHeaderCustom [HeaderName]From a custom HTTP header, useful in proxied environment.
The header value will be assumed to be a comma-separated list of IP addresses. The value will be parsed, and the left-most IP address will be used (which is mostly likely to be the actual client IP address).
Note that this still works as expected for a single IP address.
FromFallbackJust like FromHeader, but falls back on the peer address if header is not found.
FromRequest (Request -> ByteString)This gives you the most flexibility to figure out the IP source address from the Request. The returned ByteString is used as the IP source address.