Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WP-ConfigでWordPressのエラーログを設定する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressサイトのエラーログを設定したいですか?

wp-config.phpファイルはWordPressサイトの設定をコントロールします。また、このファイルを使ってエラーのログ記録をオンにすると、トラブルシューティングの際にエラーを発見して修正するのに役立ちます。

この投稿では、wp-configファイルを使ってWordPressのエラーログ記録を設定する方法を紹介する。

Setting up WordPress error logs

なぜWP-Configを使ってWordPressのエラーログを設定するのか?

wp-config.phpファイルはWordPressの重要な設定ファイルです。このファイルには、WordPress データベースへの接続方法、使用するデータベーステーブルの接頭辞、WordPress サイトをより安全にするための認証キーなどの設定が含まれています。

WordPressの初期設定とは別に、wp-configファイルを使用してWordPressのデバッグモードを有効化し、WordPressのエラーログを保存することもできます。

これは、WordPressエラーの原因となっているプラグインやスクリプトを特定することで、WordPressエラーを見つけるのに役立ちます。その後、WordPressエラーの修正方法を見つけることができます。

ということで、wp-configファイルを編集してWordPressのエラーログを有効化して設定する方法を見ていきましょう。

WP-ConfigファイルでWordPressエラーログを設定する

まず、wp-config.phpファイルを編集する必要があります。編集したことがない場合は、WordPressのwp-configファイルの編集方法をご覧ください。

FTPクライアントまたはホスティングサービスが提供するファイルマネージャーアプリを使用してサイトに接続することで、ファイルにアクセスできます。

Edit wp-config file

サイトのルートディレクトリにwp-config.phpファイルがあります。

注意:WordPressのコアファイルを編集することは危険であり、小さなエラーでも起こせばサイトを壊してしまう可能性があります。そのため、上級ユーザーのみが行うことをお勧めします。

デバッグモードの有効化

次に、テキストエディターでファイルを開き、『すべてです!ハッピー・ブログ

この行の直前に、以下のコードを追加する必要がある:

define( 'WP_DEBUG', true );

このコードがすでにwp-config.phpファイルにあり、’false’に設定されている可能性があります。その場合は、’true’ に変更してください。

この行はWordPressのデバッグモードをオンにします。これはWordPressのエラーや警告がサイトのフロントページだけでなく、管理エリア内にも表示されることを意味します。

次に、エラーログ記録を有効化して、エラーメッセージをファイルに保存する必要がある。

エラー記録の有効化

エラーをログ記録したい場合は、wp-config.phpファイルのWP_DEBUG行のすぐ下に以下のコードを追加する必要があります。

define( 'WP_DEBUG_LOG', true );

変更を保存し、wp-config.phpファイルをサイトにアップロードすることを忘れないでください。

おめでとうございます、WordPressのエラーログを有効にしました。次に、トラブルシューティングの際にログ記録を使ってエラーを見つけ、修正する方法を見ていきましょう。

WordPressのエラーログ記録を確認する

まず、WordPressサイトにアクセスし、エラーや警告が発生しているページにアクセスする必要があります。その後、WordPressホスティングサービスのcPanelでFTPクライアントまたはファイルマネージャーアプリを使用してサイトに接続する必要があります。

コンテンツに接続したら、/wp-content/フォルダーに移動します。その中にdebug.logというファイルがあります。

Debug log

このファイルをダウンロード、表示、編集することができます。

ログ記録されたWordPressのエラー、警告、通知がすべて含まれます。

WordPress errors logged

WordPressエラーのトラブルシューティングとデバッグのエキスパートガイド

WordPress のエラーログの設定方法がわかったところで、WordPress のエラーのログ記録、トラブルシューティング、デバッグに関する他のガイドもご覧ください。

この投稿が、WordPressのエラーログをwp-configファイルで設定する方法を学ぶのにお役に立てば幸いです。また、無料のビジネスメールアドレスの作成方法や、専門家が選ぶ中小企業に最適なメールマーケティングサービスもご覧ください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

14件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. mohadese esmaeeli says

    Hello and respect;
    As an additional note, I would like to inform users that the error log file becomes heavy and bulky over time. It is advisable to delete it. Each time an error occurs, this file will be recreated. Visit the WordPress installation path and check the permissions of the error_log file. If the file is unnecessary, delete it. This file contains errors that have occurred on the WordPress site.

    • WPBeginner Support says

      It would depend on how often the site has an error but it would be a good idea to delete the file every so often.

      管理者

  3. Eddy says

    Hi, quick question, one of my client’s sites has this text file error.log generated/updated under the public_html folder, yet, WP_DEBUG is set to false in wp-config, does anyone know what’s generating the error log in that file?

  4. hassu says

    My own plugin is broken, and this method does not help, the log file is empty and stays empty whatever trick i try.

  5. Zippp says

    Oh, Gosh
    If you are saying how to turn the logging on then why don’t you say how to add there any data?

    • Erick Racancoj says

      I thought the same :)

      Here is a line of code you can use once WP_DEBUG_LOG is activated:

      error_log( ‘Hello World!’ );

      • Frank Spade says

        Your test code can only work, when you use aposthrophs instead of accents! ;-)

        error_log(‘Hello World!’);

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。