ob_start();
$out = fopen('php://output', 'w');
$client = curl_init();
curl_setopt($client, CURLOPT_VERBOSE, true);
curl_setopt($client, CURLOPT_STDERR, $out);
//...
fclose($out);
$debug = ob_get_clean();
//file_put_contents($log_file, $debug);
var_dump($debug);