How to create error log in WordPress

Asked by: tomlance79
Viewed: 467
Answers: 2
  • 0


How can I create an error log file in my WordPress installation?


Answer by: jenniryan

Answered on: 21 Jul 2023 Marked as best by question author

  • 1

Open your wp-config.php file.

Find this line of code:

define( 'WP_DEBUG', false );

set it to

define( 'WP_DEBUG', true );

Then add this code below it:

if ( WP_DEBUG ) {
   @error_reporting( E_ALL );
   @ini_set( 'log_errors', true );
   @ini_set( 'log_errors_max_len', '0' );
   define( 'WP_DEBUG_LOG', true );
   define( 'WP_DEBUG_DISPLAY', false );
   define( 'CONCATENATE_SCRIPTS', false );
   define( 'SAVEQUERIES', true );

This will create a debug.log file in your wp-content folder. Once you are done debugging, make sure to set the WP_DEBUG back to false.

Answer by: tomlance79

Answered on: 20 Aug 2023

  • 0

Thanks for the answer Jenni, but it seems it doesn't work on every server. Any idea why?

Please log in to post an answer!