Logger Plugin

In a web server environment (mostly Linux or Unix based), a log writer system is very relevant  in order to track possible issues, collect statistics, obtain performance or specific details from incoming requests or connections. Monkey is not the exception about a log writer implementation, but it really is about how it differ from other web server implementations.

Monkey by it self does not know about log writer capabilities, this feature is provided by the Logger Plugin which use the potent API to perform it's job. It is distributed in the source tarball and is compiled by default. Since Monkey >= 0.12.3, the Logger Plugin works in two context levels:

  • Global Messages : If Monkey is running in console mode (not background), by default it prints to STDOUT messages about exceptions or warnings. When the plugin is enabled and Monkey runs in background mode, at startup, it will check the configuration key MasterLog which defines a file system file to redirect the global messages originally sent to STDOUT, as you should now, when you run in background mode, Monkey does not print messages, so MasterLog is the way to go to track information of the running process.
  • VirtualHost Level : When a remote client perform a request to Monkey, when it finish, the plugin will store the details of the request to the Access or Error log files. Each VirtualHost is allowed to define two log files as mentioned: an Access log file destinate to successful HTTP responses and an Error log file destinate to erroneous HTTP responses (codes 400, 404, 500...etc).

Configuration

A plugin can define it owns configuration file, as well define specific sections inside the main configuration file monkey.conf, for more details about configuration please check the official documentation .

The Logger Plugin use the configuration file conf/plugins/logger/logger.conf, which should contain something like:

[LOGGER]

FlushTimeout   3 MasterLog        /home/foo/monkey/logs/master.log

This example belongs to the global configuration where FlushTimeout specify the amount of seconds to hold log data into the buffer before to write to disk and MasterLog the target file where to store the Monkey stdout messages.

For the VirtualHost context, the plugin look for Logger Plugin sections into the virtual host configuration files, assuming that we are defining the log files for the default virtual host, reading conf/sites/default file we should have:

[HOST]

ServerName 127.0.0.1 ....

[LOGGER]

AccessLog  /home/foo/monkey/logs/access.log ErrorLog     /home/foo/monkey/logs/error.log

Now you can check with your preferred file monitor (tail -f ?) how the plugin perform and register the information, make sure you have enabled the plugin into conf/plugins.load file .