ai_logging
The recommended route now is to use the AI core module's sub-module "AI Observability".
The AI logging module allows developers to capture prompts sent to and outputs received from LLMs by other modules and store them as entities to allow for review and debugging. Whilst this module is safe to use on a production environment, it stores a large amount of data into the database and so is recommended only to aid local development or in cases where you know the AI use is sufficiently limited.
Installation
The module should be enabled as normal, which will add the bundleable AI Log entity to the site.
However, due to the large amount of data logging produces, no logging will begin until the module is configured:
- Visit /admin/config/ai/logging/settings
- Check the "Log requests" checkbox to enable logging of requests.
- If you also wish to log the response from the LLM, check the "Log response" checkbox.
- All requests sent to an LLM are tagged with the operation type being used: if you only wish to log the request and/or response from specific operations, enter their names in the "Request Tags" box. Multiple tags should be added as a comma-separated list. To find out more about the Operation Types, please refer to the Making AI Base Calls section of the documentation.
- Enter the maximum number of log entities to retain: once the number of log entries exceeds this limit, the earliest logs will be deleted.
- Enter the number of days to keep log messages for. Once any log message exceeds this age, it will be deleted regardless of the maximum retained number of logs.
- Save the configuration, and logging will begin with the next request sent to an LLM. Logs can be viewed at /admin/config/ai/logging/collection.
Alternatives
This module is maintained in a minimal state for existing sites that leveraged the AI Logging module when it was part of AI Core. It is not recommended to install this in new sites. I will update it for Drupal Core compatibility and merge major bugs but will typically not accept any feature requests.
Consider using the "AI Observability" sub-module of AI Core instead.