-
Notifications
You must be signed in to change notification settings - Fork 28
Logging
The information on this page only applies to version 1.10.0 or greater of Webmachine.
Logging in Webmachine is accomplished by an event manager process that generates event messages that may be handled by any registered event handler.
The default mode of operation does not include any registered event handler so no logging is enabled without explicit configuration.
Webmachine comes with two built-in log handlers.
Logs all webmachine access events.
An example log entry is:
127.0.0.1 - - [18/Dec/2012:22:29:35 -0700] "GET /riak HTTP/1.1" 200 2 "" "curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5"
This is a very similar output format to the access logging done by
Apache httpd
for anyone familiar with that common webserver.
A sequential description of the fields is listed below:
- Source IP of the request
- '-'
- User (currently hard-coded to a '-')
- A date and time string
- A string containing the HTTP request verb, the request path, the protocol and protocol version.
- The response status code
- The response size in bytes
- The value of the
User-Agent
header sent by the orginator of the request
Logs performance information about all webmachine access events.
An example log entry is:
127.0.0.1 - [18/Dec/2012:22:29:35 -0700] "GET /riak HTTP/1.1" 200 2 riak_kv_wm_buckets 647 6
The fields of performance log entries are as follows:
- Source IP of the request
- '-'
- A date and time string
- A string containing the HTTP request verb, the request path, the protocol and protocol version.
- The response status code
- The response size in bytes
- The resource module that handled the request
- The time to process the request and send the response in milliseconds
- The time to handle any post-request processing including gathering any notes added during the request and th log data generated by the request.
Adding a section like the following to the app.config
file enables
Webmachine logging when the application starts.
{webmachine, [
{log_handlers, [
{webmachine_log_handler, ["log"]},
{webmachine_perf_log_handler, ["log"]}
]}
]},
Log handlers may be added or removed while Webmachine is running using the following API.
- Add a log handler -
webmachine_log:add_handler(HandlerMod, Args)
- Delete a log handler -
webmachine_log:delete_handler(HandlerMod)
In the two function calls above, HandlerMod
is an atom()
reprsenting the name of the log handler module to be added or deleted.
Args
is a list of initialization parameters for the log handler
being added.
e.g. The HandlerMod
for the included access logging
module is webmachine_log_handler
and Args
would be a single item
list to indicate the directory where the access log files should be
written such as ["/tmp"]
.