Wordpress - How to log errors
On the first glance, it is easy to answer on this question. But, it is not.
Yes, you can simply set WP_DEBUG constant to true, as many sites recommend. But, probably, it comes more problems than convenience. Because, it throws out all unnecessary, for your case, messages on the site, and, most likely, just fall apart whole layout.
So, I recommend, do not switch on WP_DEBUG constant, and log what you want silently from users.
For that:
- Set WP_DEBUG constant to true.
- We need to set up WP_DEBUG_DISPLAY constant to false, to hide errors from users.
- Write where you need error_log().
After that, you can check your logs and see error messages.
If not, try to set up WP_DEBUG_LOG constant. There should be path to log file.
wp-config.php file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', '/path/to/log/file.txt' ); // if needed
Comments