37

Where does IIS 7.5 log errors?

Event Viewer? Log File?

I get a very nonspecific internal 500 error. I would like to find out more.

I'm running PHP and I did what this last comment on this post said. But still it is not logging to the C:\windows\temp folder.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
capdragon
  • 14,565
  • 24
  • 107
  • 153
  • This should probably be tagged with "iis" as well. See e.g. *[Should I not use the generic tag if my solution is limited to a specific version?](https://meta.stackoverflow.com/questions/265844/)*. – Peter Mortensen Sep 28 '21 at 15:16
  • This may be quite different on Windows compared to Linux, but for locating the PHP error log, the canonical is *[Where does PHP store the error log? (PHP 5, Apache, FastCGI, and cPanel)](https://stackoverflow.com/questions/5127838/)* (despite the over-specific title). Some of the general methods described there also work on Windows. – Peter Mortensen Sep 28 '21 at 16:24

5 Answers5

37

To report errors in Event Viewer, go to your php.ini file and make sure logging is on.

log_errors = On

Then enable error_log to write to syslog (with is Event Viewer on a Windows machines)

error_log = syslog
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
NeerPatel
  • 863
  • 6
  • 19
  • 1
    I'm wondering why this would be useful..wouldn't it be interspersed with lots of other OS/app logs? – bobsaccamano Nov 14 '14 at 11:36
  • @SandipGangakhedkar - It's user preference. I personally like having a separate log file. But some people use network monitoring tools and they only look at Event Viewers or SysLogs. – NeerPatel Nov 14 '14 at 22:55
  • 1
    You also need to ensure `error_reporting` and `log_errors_max_len` are properly set. E.g. `error_reporting=-1`, `log_errors_max_len=0`. – Pacerier Aug 27 '15 at 17:02
  • @NeerPatel, How can we set it to **server log** not `syslog` (event viewer)? By server log, I mean whatever setting IIS is currently set to. – Pacerier Aug 27 '15 at 17:25
  • @Pacerier - By Server Log, do you mean text file? If so, Do this : `error_log = C:\TEMP\PHP.LOG` – NeerPatel Aug 28 '15 at 14:46
20

For PHP v5.3, look here:

C:\Windows\Temp\PHP53_errors.log
JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
12

On my IIS 7.5 server I found this code in the php.ini file right down the bottom.

[WebPIChanges]
error_log=C:\Windows\temp\php54_errors.log
upload_tmp_dir=C:\Windows\temp
session.save_path=C:\Windows\temp
cgi.force_redirect=0
cgi.fix_pathinfo=1
fastcgi.impersonate=1
fastcgi.logging=0
max_execution_time=300
date.timezone=Australia/Canberra
extension_dir="C:\Program Files (x86)\PHP\v5.4\ext\"

I'm not sure if all of the above code is required because I'm not great with php.ini files but I can confirm the error log file is reachable and working.

This fix still requires the following if anyone is wondering.

log_errors = on
error_log = syslog
frog
  • 123
  • 1
  • 5
9

I once had a problem where the error log wasn't writeable by the PHP interpreter. I added the IUSR user to the file's security permissions (right-click the file, properties, security tab) with read write and modify permissions and was then able to see PHP errors in the log file.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JobJob
  • 3,822
  • 3
  • 33
  • 34
4

There should be a "Logging" icon on the site setup in IIS.

If you haven't changed the directory for that it looks like it defaults to %SystemDrive%\inetpub\logs\LogFiles

Look in your settings and I'd also recommend creating a logs folder above your site files to keep your logs separated.

David d C e Freitas
  • 7,481
  • 4
  • 58
  • 67
redanthrax
  • 1,684
  • 1
  • 10
  • 4