-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
access-log-destination can't be configured #147
Comments
Hi, sorry for the delay. I don't get how you're using Clack, however, generally Clack server access logs are written by Lack.Middleware.Accesslog. |
Is there a way to make access log write to a file? |
Here is the full example how to do what you want, @mdbergmann: ;; Here is the systems we need
POFTHEDAY> (ql:quickload '(:lack-middleware-accesslog :clack :dexador :log4cl))
;; First, we need to configure a log4cl to log into the access.log
;; rotated on a daily basis:
POFTHEDAY> (log:config :debug :daily "access.log")
;; Now we'll create a simple app
POFTHEDAY> (defparameter *app*
(lambda (env)
'(200 (:content-type "text/plain")
("Hello, World"))))
;; And wrap it into the middleware.
;; Here we pass a :logger to redefine
;; it to use log4cl instead of writing log to the *standard-output*.
POFTHEDAY> (defparameter *app-with-access-log*
(funcall lack.middleware.accesslog:*lack-middleware-accesslog*
,*app*
:logger (lambda (message)
(log:info message))))
;; Now it's time to start our app
POFTHEDAY> (clack:clackup *app-with-access-log*
:server :woo)
Woo server is started.
Listening on 127.0.0.1:5000.
;; And to make a test request
POFTHEDAY> (values (dex:get "http://localhost:5000/"))
"Hello, World"
;; Here what it wrote into the file
POFTHEDAY> (alexandria:read-file-into-string
"access.log")
" <INFO> [13:15:11] poftheday () -
POFTHEDAY::MESSAGE: \"127.0.0.1 - [19/Jun/2020:13:15:11 +03:00] \\\"GET / HTTP/1.1\\\" 200 12 \\\"-\\\" \\\"Dexador/0.9.14 (SBCL 2.0.2); Darwin; 19.5.0\\\"\"
" |
Thanks a lot. |
Hello ! In order to be able to configure the logs and error template locations I had to edit this file:
clack/src/handler/hunchentoot.lisp
and apply this fix:
The text was updated successfully, but these errors were encountered: