After using Hunchentoot as my HTTP server for a while I decided to switch to Clack. One of the first things I needed to do was to enable access logging. This stumped me for a while because it is not as trivial as with Hunchentoot. After digging around I found the relevant documentation.

By default Clack does not log anything. It is distributed with the <clack-middleware-accesslog> middleware which can log HTTP accesses but must be explicitly enabled.

Without any customization the code below will log to *standard-output*.


The middleware provides three methods for customization.

  1. *time-format*
    A variable to change the format used to display time.

  2. formatter
    A slot which takes a function of three parameters. It returns the formatted string which will be logged.

    The function prototype is: (defun formatter (clack-env http-result-code current-time))

  3. logger
    A slot which takes a function of one parameter. The parameter is the string to be logged. This function performs the actual logging action.

One possible customization is this:

      :logger #'model:http-access-log))