<?php
ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
ini_set('log_errors', 'On');
ini_set('display_errors', 'Off');
error_reporting(E_ERROR | E_PARSE); // Only write errors, not notices, or warnings
//error_reporting(E_ERROR | E_WARNING | E_PARSE); // if you want to also display warnings
if ( ! function_exists('write_log')) {
function write_log ( $log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
## 1) Configure the wp-config.php
As follows:
```php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
```
## 2) Add must use plugin file
Place `error-logging.php` in `wp-content/mu-plugins` folder.
## 3) Write stuff to the log
Like so:
```php
write_log( "string" );
write_log( $variable_or_array );
```