WordPress Debugging See logs in a separate file

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

When you have an ajax call, it's extremely difficult to get a log from inside of the callback function. But if you enable the debugging

define('WP_DEBUG', true);

and then after that add

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

you will have an error.log.txt file in your root folder where all your logs are located. you can even log them with

error_log( print_r( 'what I want to check goes here', true) );

inside your code. This will make your life a lot easier.



Got any WordPress Question?