a) First edit your wp-config.php
file adding the following lines to enable debug (if these are already defined, edit the values):
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
As errors are logged, they should appear in wp-content/debug.log. You can open this file in a text editor.
b) On your code: Use the following (where $variable is the variable to be displayed in the error log:
error_log( print_r( $variable, true ) );
Now you will get the data for debugging.