23
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?