Logging to file could also be useful when debugging very visual things (where you don’t want extra messages) such as themes. Also background scheduled cron jobs are the same as Ajax calls and run with no user interface so you need to send the messages to file not to the screen.
Although it is possible to configure the logging modes yourself via php.ini or .htaccess, WordPress sets up some constants in the WP_CONFIG.php file which make it simpler to setup debug logging to file.
The setting first is the master control for debugging.
Without this setting nothing will get logged.
The next setting is
This tells WordPress to log everything to the /wp-content/debug.log file, if you want to log to an alternative location do not include this setting and use the settings described in the first reference below.Finally we need to turn off the display of setting to the user (or Ajax call) using the following setting
if you set these three settings then you should have logging to file. It’s worth turning this off once your debugging session has finished as the file can get quite large quite quickly.