See Plumber Logging on R Views for a discussion of this code.
This asset shows how to log information about plumber API requests and responses by using preroute and postroute hooks. This allows information about the request and the response to be included in the log entry. The logger package is used to generate the log files.
Once these log files have been generated, a Shiny application can be used to monitor API metrics in real time. This Shiny application can even be published to RStudio Connect to monitor centralized API logs:
Code used for this example is available in this GitHub repository.