@ini_set('log_errors','On');
and
define('WP_DEBUG', true);
I’m trying to create a error log file , but i’m confusing about these two.
what kind of errors will get by log_errors
and WP_DEBUG
?
@ini_set('log_errors','On');
and
define('WP_DEBUG', true);
I’m trying to create a error log file , but i’m confusing about these two.
what kind of errors will get by log_errors
and WP_DEBUG
?
You must be logged in to post a comment.
The
define('WP_DEBUG_LOG', true);
will log errors into the debug.log file in the wp-content directory,@ini_set('log_errors','On');
allows you to specify the file where you want to save it. This should work for you:The
@ini_set('log_errors','On');
option sets the PHP handler to log errors. It is a general configuration option used to control script’s behaviour. More on the function hereThe
define('WP_DEBUG', true);
on the other hand is very WP specific, it is used to capture and either print to screen / write to file WP specific errors. More on it here.Writing to a log file
PHP stores error logs in
/var/log/apache2
if PHP is an Apache2 module. Shared hosts are often store log files in your root directory/log
subfolder.If you have access to a php.ini file you can specify the path like this:
You can tell WP to log entries to a file by setting
define( 'WP_DEBUG_LOG', true );
. That causes all errors to also be saved to adebug.log
log file inside the/wp-content/
directory.If you quickly want to inspect a function or a variable then try something like this
error_log($my_error, 3, "/var/tmp/my-errors.log");
. Its a handy function, more details here.What you use depends on your requirement and what you want to debug.