The following code shows how to log HTTP requests made in WordPress using wp_remote_get().
This can can give you valuable insights into what your WordPress site is doing and it’s performance.
- Use the “http_api_debug” hook to enable logging, by adding the following code snippet to your functions.php file:
function simple_http_debug_logger( $response, $context, $class, $parsed_args, $url ) { error_log( 'http_debug: '.$url ); } add_action('http_api_debug', 'simple_http_debug_logger', 10, 5);
- Make sure you’ve enabled WP_DEBUG and WP_DEBUG_LOG.
- Every request made will be logged in the debug.log file