logger
lib/middleware/logger.js.token()
Define a token function with the given name,
and callback fn(req, res).
.undefined()
Define a fmt with the given name.
Define a token function with the given name,
and callback fn(req, res).
Define a fmt with the given name.
Log requests with the given
optionsor aformatstring.Options
formatFormat string, see below for tokensstreamOutput stream, defaults to stdoutbufferBuffer duration, defaults to 1000ms when trueimmediateWrite log line on request instead of response (for response times)Tokens
:req[header]ex::req[Accept]:res[header]ex::res[Content-Length]:http-version:response-time:remote-addr:date:method:url:referrer:user-agent:statusFormats
Pre-defined formats that ship with connect:
default':remote-addr - - [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"'short':remote-addr - :method :url HTTP/:http-version :status :res[content-length] - :response-time ms'tiny':method :url :status :res[content-length] - :response-time ms'devconcise output colored by response status for development useExamples
Defining Tokens
To define a token, simply invoke
connect.logger.token()with the name and a callback function. The value returned is then available as ":type" in this case.Defining Formats
All default formats are defined this way, however it's public API as well: