どうも!スカーレット坊やです。
今回はXAMPPでPHPのエラーログを出すやり方を書いていこうと思います。そもそもなんでこれを書いているのかというと…
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
うおおぉお…ちょっ…
![](https://s-carlett.com/wp-content/uploads/2022/08/500.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/08/500.jpg)
突然出ました。Elementorを使ってページ編集・制作を行っていた時に現れました。
サーバーエラー(500 error)
注意)今回はこの500エラーを解決するのが目的の記事ではありません。この500エラーが、大題のXAMPPでPHPエラーログを出すきっかけとなりました。elementorの500エラーの多くはメモリ不足などで起きるのですがそれを解消しても解決しませんでした。
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
コロさん、なにか出た、ググってみたけど良くわかりません…
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
ふむ…通常のメモリ不足ではないとするとまずは原因の究明からですね。エラーログを出してみてもらえますか?
XAMPPでPHPエラーログを出す前提
・パソコンにXAMPPがインストールされていること
まだXAMPPのインストールが終わっていない方が、こちらを参考にインストールしよう
![](https://s-carlett.com/wp-content/uploads/2022/08/37220c8d6018b08af9f69149fd69aeae-300x157.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/08/37220c8d6018b08af9f69149fd69aeae-300x157.jpg)
XAMPPでのPHPエラーログの出し方
![](https://s-carlett.com/wp-content/uploads/2022/09/error-g56ed4bcda_640.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/09/error-g56ed4bcda_640.jpg)
手順1:ログフォルダを作成しよう
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
Cドライブ → XAMPP → PHP この PHPフォルダ内に「新規フォルダ作成」で「logs」というフォルダを作ってください
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996142899.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996142899.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
できました!
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
では次にXAMPPパネルを開いていただき、
Apacheの列のConfigボタンをクリックしてPHP(php.ini)を選択しましょう
![](https://s-carlett.com/wp-content/uploads/2022/09/1661993901854.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/09/1661993901854.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
はい、え~と、php.iniファイルが開きました
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
OKです、ではCtrl+Fキーで検索ウィンドウを出していただき、「log_errors」で検索してください。
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996284393.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996284393.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
log_errors=Off というものがあると思いますので
log_error=On に書き換えて保存をお願いします。
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996257329.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996257329.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
分かりました、大丈夫です、出来ています
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
はい、同じく検索ウィンドウで、今度は
「;error_log = php_errors.log」で検索していただき
頭の「;」を外してください。(もともと外れているならそのままでOKです)
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996318657.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/09/1661996318657.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
はい、書き換え完了、保存します。
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
OK、では一度XAMPPを再起動してください。この時にXAMPPパネルでApacheをStopして止める事を忘れずに!ですよ
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
分かりました、よし、再起動できました
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
ではもう一度エラーを再現して、ログを見てみましょう!
![](https://s-carlett.com/wp-content/uploads/2022/09/21830aIMGL99761973_TP_V4.jpg)
![](https://s-carlett.com/wp-content/uploads/2022/09/21830aIMGL99761973_TP_V4.jpg)
ログファイルを見てみよう
メンターさんの言う通り、エラーを再現したスカ坊であった。
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
エラーの再現ができました(怖いわ~)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
はい、では先程作った「logs」フォルダの中にエラーログがあると思いますの
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/fabicon-150x150.png)
おぉ~ありました!ちゃんとログを出しています!
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
![](https://s-carlett.com/wp-content/uploads/2022/08/koro-150x150.png)
トラブルが解消したらエラーログは出さなくていいので、設定をもとに戻しておいてくださいね。「logs」フォルダは残しておいても構いません。
さて、今回はここまでです。
無事にエラーログを出すことが出来たスカ坊は、このあとメンターさんにログを見ていただき、エラーを特定して解決していくのですが、それはまた別のお話になります。
プログラムエラーは原因究明がキー
今回のように、意味不明なエラーというのはいつどこで起きるかわかりません。WordPressでは初心者の大体はお手上げになります。
でも待ってください。何もせずにお手上げになるのと、少しでもなにか出来ることを知っているのは大きな違いがあります。エラーが発生した時には
- できるだけ情報を集めてググる
- ググった結果をもとにいろいろ試して解決を試みる
これはこういった業務をされるかたでしたら誰もが行うことだ思いますが、是非この解決方法に「エラーログを取得して、再度検索をする」という方法を加えてもらえるとうれしいです!
有識者に問い合わせるときもエラーログは必ず見せてと言われます
スカ坊も冒頭で言われていましたね! ですので、常に出せるようにしておこう!
こちらも併せてぜひお読みください。
エラーにビビってるじゃないか
「坊やだからさ」
それではまた!