Is there any way to turn on logging for API calls?
We have a third party application that is having trouble working with our store and would like to get some debuggging info. ~I have searched bt found nothing.
I'm using 1.7
Logs provide insight into system processes of Magento 2 and are a great tool for tracking errors, significant events, exceptions and many more. In order for the logging library to be properly implemented with Magento 2, it must comply with PSR-3 standard.
Magento API is a type of framework that offers developers and integrators a good method to maximize web services which communicate well with the Magneto system. Amongst the primary features are supports for SOAP (Simple Object Access Protocol) and REST (Representation State Transfer).
for a controlled period of time you can manipulate your index.php like so:
put this code at the end of the index.php around the ::run call:
ob_start();
Mage::run($mageRunCode, $mageRunType);
if(preg_match('/api/', $_SERVER['REQUEST_URI'])) {
Mage::log('<<< request '.$_SERVER['REQUEST_METHOD'].': '.$_SERVER['REQUEST_URI'], null, 'api.log');
if($_SERVER['REQUEST_METHOD'] == 'POST') {
Mage::log('<<< '.file_get_contents('php://input'), null, 'api.log');
}
Mage::log('>>> '.ob_get_contents(), null, 'api.log');
}
ob_end_flush();
its quick and dirty but for adhoc debugging it works
A really good solution is to use an API proxy. It's not as complex as it sounds. It's just a PHP script you point your API calls to instead of the the normal API URL. The idea is that it logs every incoming API request before passing it onto the normal magento API. It also logs the responses before passing it back to the client.
There's a ready built one right here which I've used in the past to diagnose many API issues. http://techcolin.net/2011/11/a-php-proxy-script-for-logging-magento-api-soap-calls/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With