Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To log WordPress errors without showing them to visitors, enable WP_DEBUG and WP_DEBUG_LOG, then set WP_DEBUG_DISPLAY to false in the active wp-config.php. The default log is wp-content/debug.log. Because that file can be publicly reachable and may contain sensitive details, use staging when possible and protect or remove the log after troubleshooting.

Enable the WordPress debug log

Open wp-config.php in your WordPress installation root using your host’s file manager, SFTP, FTP, or shell access. Add this block above /* That's all, stop editing! Happy blogging. */:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

These settings follow the [WordPress debugging guidance]. WP_DEBUG turns on WordPress debug mode; WP_DEBUG_LOG writes errors to a log when debug mode is enabled; and WP_DEBUG_DISPLAY suppresses debug messages in generated HTML. The display_errors setting also asks PHP not to print errors to the page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the file already defines any of these constants, edit or reconcile the existing definitions rather than adding duplicates. Use the boolean value true or false without quotation marks: in PHP, the string 'false' is truthy and will not disable debugging.

Find and read the log

With WP_DEBUG_LOG set to true, WordPress uses wp-content/debug.log. You can instead set it to a valid filesystem path, such as:

define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );

Choose a location your PHP process can write to, and make sure you can retrieve it. Use a hosting file manager, SFTP, FTP, or shell access to inspect the file. Debug mode raises error reporting to E_ALL, so the log can include PHP errors, warnings, notices, and deprecation messages—not only fatal errors. See the [WordPress debugging documentation] for the supported logging configuration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Protect logs on a public site

WordPress recommends using debug tools on local or staging installations rather than live sites. If you must troubleshoot production, keep messages hidden from pages and take steps to prevent access to the log. A log in a public web directory may be readable by anyone, and its contents can expose implementation details or sensitive data. WordPress specifically cautions that publicly accessible logs should be deleted after use: [debugging and logging guidance].

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

SaleBestseller No. 1
SaleBestseller No. 3
Bestseller No. 4
Teacher Record Book
Teacher Record Book
Keep track of everything from attendance to test scores; Spiral bound; Measures 8-1/2" x 11"
$4.89
Rank #4
Teacher Record Book
  • Keep track of everything from attendance to test scores
  • Spiral bound
  • Measures 8-1/2" x 11"
  • Prefer a development or staging copy when it can reproduce the issue.
  • When production logging is necessary, use a protected location outside the public web root if your setup allows it.
  • Restrict file permissions and block HTTP access to any log that remains within the web root.
  • Turn logging off and remove the log when you have collected what you need.

Troubleshoot a missing or unhelpful log

  1. Verify that you edited the active wp-config.php in the WordPress installation root.
  2. Check that the definitions are above the stop-editing comment and that WP_DEBUG is the boolean true.
  3. Reproduce the failing action. If it occurs during an AJAX request or scheduled task, reproduce that activity too.
  4. Open wp-content/debug.log or the custom path you configured. Note the timestamp, error type, file, and line number for the relevant entry.
  5. Use that evidence to investigate the responsible plugin, theme, or PHP issue.
  6. After troubleshooting, set WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY to false, keep PHP display_errors off, and remove the log when it is no longer needed.

Choose the right logging setup

Choice Configuration or use Trade-off
Default destination WP_DEBUG_LOG set to true; WordPress writes to wp-content/debug.log. Simple to locate, but the file may be under a publicly accessible web directory.
Custom destination Set WP_DEBUG_LOG to a valid filesystem path, such as /tmp/wp-errors.log. Can be placed outside the public web root, but must be writable by PHP and accessible to you.
Log without page output Set WP_DEBUG_DISPLAY to false and PHP display_errors to 0. Reduces visitor exposure while retaining diagnostic details in the log.
Development or staging Enable debug logging on a non-public test copy when possible. Generally safer for diagnosis; the copy still needs to reproduce the problem.
Production troubleshooting Enable only when needed, keep display disabled, and protect the destination. Can capture a live-only issue, but increases the risk of exposing sensitive log contents.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.