16

php.ini contains following parameters:

track_errors=On
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors=On
error_log="C:\xampp\php\logs\php_error_log"

but "logs" folder is missing in this path. Its not even hidden folder. where to find php error logs?

OS:windows 8.1
php version 5.6.24
ScottyG
  • 3,204
  • 3
  • 32
  • 42
Soumya Agrawal
  • 159
  • 1
  • 1
  • 8

3 Answers3

50

Somehow PHP won't create the "logs" folder by itself... and that's what we need to do:

  1. Created the "logs" folder in the correct location (for instance, C:\xampp\php\logs).

  2. Restart Apache using XAMPP control panel (stop and start).

Then when an error occurs the file will be generated fine and you'll be again able to open the PHP logs from XAMPP console

XAMPP PHP logs

To test that it's working you can create a fatal error by using

trigger_error("Some info",E_USER_ERROR);
Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Jos Luijten
  • 621
  • 5
  • 9
  • 2
    Thanks so much for posting this! – JimB814 Dec 19 '17 at 16:59
  • 4
    It turns out that just creating the folder is enough, you don't have to stop/start the server. – mgroat Feb 05 '18 at 12:50
  • 1
    I like the trigger_error trick, I didn't know about it. I've always achieved this with `$kaboom=3/0;` to get a `Division by zero` error :-) – pgr Jun 22 '18 at 16:45
  • 3
    @ValRob you need to check your php.ini. The default location should be `C:\xampp\php`. create here the folder `logs`. This solved the problem for me – Michael Walter Oct 09 '18 at 09:34
  • @jos-luijten dear sir, i have tried your solution.. but still not logs comes in that folder and also php (on browser) does not showing any error :(. I have checn my php ini and all settings are correct there. – Zakir_SZH Nov 21 '18 at 06:24
  • @Zakir_SZH, than I am sorry, I don't know how to help you. Hopefully you succeded by now?! – Jos Luijten Jan 05 '19 at 20:28
  • @pgr lol funny enough I was also missing the log file. I created the logs folder in ```C:\xampp\php\logs``` then added your variable and boom my log file created lol :D – demo7up Sep 06 '19 at 14:56
  • This just solved my problem. – Roger May 17 '23 at 20:39
4

In my case I solved this problem by making the main settings made in the question, with only two changes:

track_errors=On
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors=On

change 1:

error_log="C:\xampp\php\logs\php_errors.log"

in the documentation it says that these methods are deprecated, so it is disabled by default and with the wrong directory.

change 2:

Create the folder 'logs' in: C:\xampp\php

This worked for me, I hope it will be useful.

-1

If you are sure that you are using the right config option to set the log path, it might be that PHP is not writing to the error log because of a certain type of syntax error. Put your code through a syntax checker like http://phpcodechecker.com/

Jesse Schokker
  • 896
  • 7
  • 19
  • i haven't made any changes in php.ini, so this doesn't seems like syntax error in php.ini. moreover my php files doesn't show any syntax error in provided link.("php. **ini** " can't be checked in this link) – Soumya Agrawal Apr 06 '17 at 07:57
  • I am talking about the actual PHP file. Like I said, with some syntax errors it might be that the error is just not logged. If it is the standard, unedited php.ini file, I doubt that there are any errors. Is the PHP/WebServer process starting fine? – Jesse Schokker Apr 06 '17 at 07:59
  • yes server is working absolutely fine. and actual PHP files doesn't have any syntax errors. – Soumya Agrawal Apr 06 '17 at 08:51
  • If a syntax error would occur, PHP would tell you that, regardless of any error log configuration – Nico Haase Dec 11 '20 at 16:55