{"action":"created","issue":{"url":"https://api.github.com/repos/yesodweb/yesod/issues/1276","repository_url":"https://api.github.com/repos/yesodweb/yesod","labels_url":"https://api.github.com/repos/yesodweb/yesod/issues/1276/labels{/name}","comments_url":"https://api.github.com/repos/yesodweb/yesod/issues/1276/comments","events_url":"https://api.github.com/repos/yesodweb/yesod/issues/1276/events","html_url":"https://github.com/yesodweb/yesod/issues/1276","id":175485864,"number":1276,"title":"Log request and response","user":{"login":"lippling","id":85933,"avatar_url":"https://avatars.githubusercontent.com/u/85933?v=3","gravatar_id":"","url":"https://api.github.com/users/lippling","html_url":"https://github.com/lippling","followers_url":"https://api.github.com/users/lippling/followers","following_url":"https://api.github.com/users/lippling/following{/other_user}","gists_url":"https://api.github.com/users/lippling/gists{/gist_id}","starred_url":"https://api.github.com/users/lippling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lippling/subscriptions","organizations_url":"https://api.github.com/users/lippling/orgs","repos_url":"https://api.github.com/users/lippling/repos","events_url":"https://api.github.com/users/lippling/events{/privacy}","received_events_url":"https://api.github.com/users/lippling/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-07T12:07:54Z","updated_at":"2016-09-08T10:54:17Z","closed_at":null,"body":"How can I log request and response headers/bodies when the status is 4xx oder 5xx?\r\n\r\nI have this scaffolded function:\r\n\r\n```haskell\r\nmakeLogWare :: App -> IO Middleware\r\nmakeLogWare foundation =\r\n    mkRequestLogger def\r\n        { outputFormat =\r\n            if appDetailedRequestLogging $ appSettings foundation\r\n                then Detailed True\r\n                else Apache\r\n                        (if appIpFromHeader $ appSettings foundation\r\n                            then FromFallback\r\n                            else FromSocket)\r\n        , destination = Logger $ loggerSet $ appLogger foundation\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/yesodweb/yesod/issues/comments/245562525","html_url":"https://github.com/yesodweb/yesod/issues/1276#issuecomment-245562525","issue_url":"https://api.github.com/repos/yesodweb/yesod/issues/1276","id":245562525,"user":{"login":"snoyberg","id":49415,"avatar_url":"https://avatars.githubusercontent.com/u/49415?v=3","gravatar_id":"","url":"https://api.github.com/users/snoyberg","html_url":"https://github.com/snoyberg","followers_url":"https://api.github.com/users/snoyberg/followers","following_url":"https://api.github.com/users/snoyberg/following{/other_user}","gists_url":"https://api.github.com/users/snoyberg/gists{/gist_id}","starred_url":"https://api.github.com/users/snoyberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snoyberg/subscriptions","organizations_url":"https://api.github.com/users/snoyberg/orgs","repos_url":"https://api.github.com/users/snoyberg/repos","events_url":"https://api.github.com/users/snoyberg/events{/privacy}","received_events_url":"https://api.github.com/users/snoyberg/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T10:54:17Z","updated_at":"2016-09-08T10:54:17Z","body":"You'd need to handle that manually, the logging middleware doesn't have that support out of the box. Keep in mind that, in order to make that happen, you'll need to cache the entire request body contents for every request, since you won't know until _after_ the application has consumed the request body if you want to log it.\r\n\r\nThe code inside the logging middleware module gives some examples of how to do this kind of caching, and could be a good basis for a custom middleware."}}
{"actor":{"display_login":"snoyberg"}}