This module allows developers to capture and store prompts sent to and outputs received from LLMs as entities. This enables review and debugging of AI interactions. It is recommended to configure storage limits to manage the large amount of data generated.
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 to keep the maximum quantity and time limits enabled for the amount of logs to store.
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.
Drush commands
E.g. drush ai:logs; see the Drush Commands file for full options.
When to use
This module is maintained and compatible with the AI Logging module when it was part of AI Core. It is heavier than AI Observability because it uses a fieldable entity system to store each log as an AI Log.
Consider using the "AI Observability" sub-module of AI Core instead. There is no migration path between the two.