Is there any way to log all the requested rest API with details (requested URL, methods, parameters, time, etc.,) in Magento2?

earlier I have logged all the rest of the API which was related to products using the model (V1.php) in Magento 1. but in magento2 all the methods called in the same location for both API and backend usage to create/update/get.

here how can I know if the request from API?

Please suggest any solution to log APIs.



[This may not be a good way to log the Rest API]

We should try with Plugin - Magento\Webapi\Controller\Rest::dispatch():


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="Magento\Webapi\Controller\Rest">
        <plugin name="rest-api-log"



namespace Vendor\WebApiLog\Model\Plugin;

class RestApiLog
    public function beforeDispatch(
        \Magento\Webapi\Controller\Rest $subject,
        \Magento\Framework\App\RequestInterface $request

  • how to get the params in this dispatch method, i tried $request->getParams(); it returns the empty array. even $request->getModuleName(); $request->getActionName(); these two methods also returns null value. – Sathish Mar 30 '17 at 7:49
  • @Sathish all of the methods above returns null value? – Khoa TruongDinh Apr 2 '17 at 14:56
  • 3
    not all some of the methods. i used $request->getContent() to collect the inputs. thanks – Sathish Apr 4 '17 at 6:40

You can use the following FOSS module:


  • Does not seem to work on Magento 2.4 at this time. – Liam Mitchell Jan 21 at 3:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.