Skip to main content
Published: March 14 2013, 3:26:00 PMUpdated: August 29 2022, 4:31:57 PM

Suppose that the Request Xml, after being constructed, is stored in the variable - $requestXml, and Response XML, after retreival from eBay, is stored in $responseXml.

PHP provides a library function, error_log to log any strings to local log files, or default PHP error logs.

error_log(var_export($requestXml,true), 3, "/path/to/logFile.log");

// $requestXml - XML to be logged. var_export(with param- true), returns a parsable String representation of the variable, If the variable is not already a string.

// The param 3 - denotes message is appended to the file destination. A newline is not automatically added to the end of the message string.

Similarly, for logging response

error_log(var_export($responseXml,true), 3, "/path/to/request-response.log");

You can also email the logs and log the messages with different flags. Please see Official reference for more information.

How well did this answer your question?
Answers others found helpful