I am using an IIS 7.5 on Windows Server 2008 R2 together with PHP 5.5 NTS via FastCGI. Somehow my PHP does not want to log errors to a file. The file never gets created and when I create it manually, PHP does not write into it.
This is my php.ini (verified, that it's the one that gets loaded with phpinfo(); )
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = On
error_log = "C:\inetpub\logs\php\php_errors.log"
The specified directory has write access for IIS_IUSRS, IUSR and even the AppPool User (yes I know its redundant, just to make sure). I even turned on display_errors to see if there is an error and it does display the error in my browser but PHP still doesn't want to write an error log.
Edit: [SOLVED]
I was using BasicAuthentication for my website and there the IIS impersonates the user you are logging in with. Therefore I just added my log on user account to the IIS_IUSRS group and now it works.
The ini_set(“log_errors”, TRUE) command can be added to the php script to enable error logging in php. The ini_set('error_log', $log_file) command can be added to the php script to set the error logging file. Further error_log($error_message) function call can be used to log error message to the given file.
The location of the error log file itself can be set manually in the php. ini file. On a Windows server, in IIS, it may be something like "'error_log = C:\log_files\php_errors. log'" in Linux it may be a value of "'/var/log/php_errors.
Adding this as a solution text so that it no longer appears on the Unanswered questions list. Answer is provided by question author in the edited question above:
Edit: [SOLVED]
I was using BasicAuthentication for my website and there the IIS impersonates the user you are logging in with. Therefore I just added my log on user account to the IIS_IUSRS group and now it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With