LoginSignup
23
23

More than 5 years have passed since last update.

WordPress のデバッグ

Last updated at Posted at 2012-09-16

WP_DEBUG_LOG を使うと、エラーログや任意のログを wp-content/debug.log に出力できます。

wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
functions.php
if(!function_exists('_log')){
  function _log($message) {
    if (WP_DEBUG === true) {
      if (is_array($message) || is_object($message)) {
        error_log(print_r($message, true));
      } else {
        error_log($message);
      }
    }
  }
}

としておいて、以下のようにすると使えます。

_log("Hello, World!");

ログファイルが外から見える場所なので、本番環境では使わない方がよさそうです。

参考
http://codex.wordpress.org/Debugging_in_WordPress

23
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
23