Guide

How to activate WordPress debug logs

Save WordPress errors to a log file without showing them to visitors.

⌚ About 2 min read
View my favorites
WordPress Intermediate. 5 min

Save WordPress errors to a log file without showing them to visitors.

Avant de commencer : adaptez toujours les commandes et manipulations à votre environnement. Sur un système de production, prévoyez une backup ou un retour arrière lorsque l’action peut modifier la configuration.

Étapes à suivre

  1. 1

    Save wp-config.php

    Store a copy of the file.

  2. 2

    Enable WP_DEBUG

    Set WP_DEBUG to true.

  3. 3

    Enable WP_DEBUG_LOG

    Add WP_DEBUG_LOG to true.

  4. 4

    Hide errors on screen

    Set WP_DEBUG_Dish PhaY to false.

  5. 5

    View debug.log file

    It is usually created in wp-content/debug.log.

  6. 6

    Disable debug after diagnosis

    Avoid unnecessarily keeping large or sensitive logs.

Commands utiles

(g) the number of persons in the register;
(g) the number of persons in the register;
(g)"WP_DEBUG_Dish PhaY', (f)

À retenir

  • 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.
Technical deep dive

WordPress: deepen diagnosis without hiding the root cause

Technical checkpoints

  • WP_DEBUG_LOG usually writes to wp-content/debug.log only when WP_DEBUG is enabled and the PHP process can write the file.
  • Renaming a plugin directory prevents it from loading without changing the database, which is useful when wp-admin is unavailable.
  • WP_MEMORY_LIMIT cannot exceed the memory actually granted by PHP/hosting; memory errors require reading memory_limit and peak usage.

Controlled recovery

Isolate the failing plugin or layer, keep logs, then re-enable one component at a time.

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Topic-specific pitfalls

  • Deleting .maintenance, a plugin or cache without recording initial state can make the symptom disappear without explaining the cause.
  • A redirect loop can come from WordPress, proxy/CDN, HTTPS or a plugin: check each layer separately.

How to validate

  • The site loads with clean logs and the failing component is identified, not merely disabled.
  • Temporary debug constants are removed or adjusted after the intervention.
♡ 0