You can enable WordPress logging adding this to wp-config.php:
1 2 3 4 5 | // Enable WP_DEBUG mode define( 'WP_DEBUG', true ); // Enable Debug logging to the /wp-content/debug.log file define( 'WP_DEBUG_LOG', true ); |
you can write to the log file using the error_log() function, this is a very useful function wrapper for it, make it available in your plugin:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (!function_exists('write_log')) { function write_log($log) { if (true === WP_DEBUG) { if (is_array($log) || is_object($log)) { error_log(print_r($log, true)); } else { error_log($log); } } } } write_log('THIS IS THE START OF MY CUSTOM DEBUG'); //i can log data like objects write_log($whatever_you_want_to_log); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.