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.
Suppose I have a web application:
When I start the web server and access the web app through the browser, the logs appear like this:
The HTTP response code is missing from the logs, making it difficult to know when any of the web pages result in
500
,403
,404
, etc.Would it be possible to implement request + response logging? Request + response logs are more useful in tracking past errors. For example:
(Originally asked on Stack Overflow: https://stackoverflow.com/questions/53911162/)
The text was updated successfully, but these errors were encountered: