This module creates a REST endpoint that allows you to log messages to Drupal's database log. You can send log entries as JSON data, specifying the message, its severity, the path, and the channel. This provides a programmatic way to record information in Drupal's watchdog log.
Synopsis
This module provides a REST endpoint for logging messages to Drupal's core logger using JSON with a message value, severity, path, and channel value as documented on the Drupal Logging API documentation.
Requirements
This module requires the following core modules:
Recommended modules
- REST UI module: When enabled, it displays active REST endpoints at Configuration > Services > REST.
Installation
Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.
Configuration
- Enable the module at Administration > Extend.
- Grant the desired permissions needed to the
POST log messagespermission and theAccess POST on Watchdog database logger resourcepermission via the People > Permissions page.
Example JSON POST Body
Required Values:
- message
- path
Default Values:
- The default value for
channelisrestfulloger. - The default value for
severityisNotice.
{
"message": "The message you want to log.",
"severity": "Error",
"channel": "module_machine_name",
"path": "/path/to/page"
}
Troubleshooting
If the logger does not get recorded when POSTing to /dblog/logger
- Ensure the
POST log messagesandAccess POST on Watchdog database logger resourcepermissions are set to the correct roles on the People > Permissions page. - Ensure the REST endpoint is enabled. (This is easier to check using the REST UI module.)
- Ensure your JSON body is formatted correctly and the
messageandpathvalues are defined.
Credits
Ask your assistant about RESTful Logger
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- rest Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.