request_logger
Logs every HTTP Request to the website with the response data details to the standard logger, including responses returned directly from cache. Stores in the log entry useful metadata about the request (request type (GET/POST), path, query string, headers) and the response (response generation duration in milliseconds, size, memory usage, cache hit/miss, headers, etc).
This data is very useful to monitor the site performance, cache hit rate monitoring and build other site analytics reports.
Usage
Just install the module, and it works out of the box, adding a new log entry for each request to the website.
On the settings page /admin/config/development/request_logger (Home » Administration » Configuration » Development » Request Logger) you can choose what exact data you want to store in the logs.
Extended structured logs
By default, this module works well with the default Drupal loggers - Syslog and DBlog and stores the simple information in the log message.
But you can extend the log entry data using the Logger module to store all required custom fields and metadata together with the log entry. This approach allows aggregate, filter and sort logs by any custom field (eg, sort requests by duration or memory usage), build metrics, reports, and charts directly from logs using any log visualizing tool.
A submodule "Request Logger Reports" provides displaying logged requests and responses directly in the Drupal Admin Panel with the ability to filter by any custom field using the Logger DB module, and even build useful charts with the help of the Charts module.
Log entry example
{
"timestamp_float": 1759500536.654993,
"message": "GET /node - query: page=2, response: duration: 0.227 sec, memory: 3.518 MB, page cache: HIT",
"channel": "request_logger",
"severity": 6,
"uid": 0,
"metadata": {
"request": {
"method": "GET",
"path": "/mode",
"query": "page=2",
"uuid": "a5e06180-6348-4dcd-920f-91386a34dc21"
},
"response": {
"code": 200,
"size": 42749,
"duration": 0.227,
"memory_usage": 3688552,
"memory_usage_peak": 5021640,
"page_cache": "HIT"
}
}
}Previous version (2.x)
The previous approach in the 2.x branch extends and overrides the core DB Logger service to add HTTP request data to the logs. Especially useful for decoupled sites, where you need to see what POST requests caused PHP exceptions or other 5xx errors.
Usage:
- Install and enable the module.
- All log entries with a severity of ERROR or higher (i.e. RFC 5424 numerical code lower than or equal to 3) will include extra information about the HTTP request in the DB logs at `/admin/reports/dblog`.
Fund the project at: www.refstudycentre.com/contact#donations