Save WordPress errors to a log file without showing them to visitors.
Steps….
- Save wp-config.php — Store a copy of the file.
- Enable WP_DEBUG – Set WP_DEBUG to true.
- Enable WP_DEBUG_LOG — Add WP_DEBUG_LOG to true.
- Hide errors on screen — Set WP_DEBUG_Dish PhaY to false.
- View debug.log file — It is usually created in wp-content/debug.log.
- Disable debug after diagnosis – Avoid unnecessarily keeping large or sensitive logs.
Commands
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
Key takeaways
- Do not publicly share a debug.log without examining it: it may contain sensitive paths, queries or information.
- On a public site, hide the direct display of errors.