Log things to debug-custom.log

Log things to debug-custom.log

If you have WP_DEBUG set to true, you have probably noticed that the debug.log file soon ends up getting messed up with messages that don’t entangle you at all. But you can create an alternative log file where only your messages will be logged! In the functions.php file add this:
function custom_log( $message ) {
	$log_file = WP_CONTENT_DIR . '/debug-custom.log';
	if ( is_array( $message ) || is_object( $message ) ) {
		error_log( print_r( '[' . gmdate( 'Y-m-d H:i:s' ) . '] ' . $message, true ), 3, $log_file );
	} else {
		error_log( '[' . gmdate( 'Y-m-d H:i:s' ) . '] ' . $message . "\n", 3, $log_file );
	}
}

To log only what is really important to you! 📜