see var_dump dump in log file code example
Example: var_dump to log
// Using print_r()
$object = new MyObject();
error_log( print_r( $object, true ) );
// Using var_dump()
function var_error_log( $object=null ) {
ob_start(); // start buffer capture
var_dump( $object ); // dump the values
$contents = ob_get_contents(); // put the buffer into a variable
ob_end_clean(); // end capture
error_log( $contents ); // log contents of the result of var_dump( $object )
}
$object = new MyObject();
var_error_log( $object );