You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#lang racket
(require web-server/servlet-env)
; Some web app code here ...;; Start the web server.
(serve/servlet request-handler
#:log-file"/dev/stdout")
When I start the web server and access the web app through the browser, the logs appear like this:
First, the existing request logging system is fully parameterized for you to make custom log formats. You can use the #:log-format argument and browse the existing options in the web-server/dispatchers/dispatch-log module.
Second, the way to do to this is to wrap your response creation function in something that intercepts and logs. The server is set up so all responses come from (-> request response) functions, so if you are currently using f change it to (log&return req (f req)) where log&return makes the log you want and then returns it up. I am happy to merge this into the main repo if it is clean. It should be quite straight-forward to do.
Activity
jeapostrophe commentedon Jan 29, 2019
First, the existing request logging system is fully parameterized for you to make custom log formats. You can use the
#:log-formatargument and browse the existing options in theweb-server/dispatchers/dispatch-logmodule.Second, the way to do to this is to wrap your response creation function in something that intercepts and logs. The server is set up so all responses come from
(-> request response)functions, so if you are currently usingfchange it to(log&return req (f req))wherelog&returnmakes the log you want and then returns it up. I am happy to merge this into the main repo if it is clean. It should be quite straight-forward to do.