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:

  1. Set WP_DEBUG constant to true.
  2. We need to set up WP_DEBUG_DISPLAY constant to false, to hide errors from users.
  3. 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

Popular posts from this blog

CSS Как прикрепить слой (div) к краю

MySQL - How to add JSON column type

Как сделать заголовок модуля активной ссылкой в Joomla 1.5