Changing the location of the PHP error log file - php

I use PHP version 5.3.19, Windows Server 2008 R2 Standard SP 1 and Internet Information Services (IIS) 7.5.7600.16385.
My problem:
I can't change the PHP error log file location.
When I try that and restart the IIS service, my web application cannot be opened:
Browser says 500 - Internal server error.
I tried everything.
I checked the error logs of Windows and the IIS error log.
Nothing! Is this possible?
I was able to change the locations of the PHP session data folder and the PHP upload temp folder, no problem. (I created a folder, C:\myapplication\mycompany\temp, and gave this new folder all the necessary rights, so the IIS IUSR can do everything.)
So: The new locations of the PHP session data folder and PHP upload temporary folder work after restart of the IIS service! That's fine!
But I cannot change the location of the PHP error log file. Why?
It is the same new Windows folder having the ultimate rights.
I tested a little bit with different text files.
I created new and empty log files, tested with the original PHP error log file from C:\Windows\Temp. Nothing. And I really restarted the IIS service after every change of the php.ini file. But in the end: The browser says 500 - Internal server error when browsing the web application.
So, what can I do? I don't understand what's wrong.

You may be setting the error logs in file php.ini.
Try setting it at runtime with something like:
ini_set('display_errors', 'on');
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
ini_set('error_log', "C:\php\error.log");
That way, you should see the error message on screen, it there is one.

Related

GoDaddy Windows Plex PHP error_log not working right

I'm having an issue where I get an "Internal Server Error" on my php page. To try and debug it, I attempted to use the error_log function in php. However I could not get it to write anything to the error log. Even in a simple php file:
httpdocs/temp.php
<?php
error_log("this is an error");
echo "hello";
?>
I would receive a basic internal server error message:
Internal Server Error The server encountered an internal error or
misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the
error occurred and of anything you might have done that may have
caused the error.
More information about this error may be available in the server error
log.
Web Server at xxxxxxxx.com
So I looked up how to set up the error_log properly, thinking that it was somehow not set up correctly. I found this article.
Since I am on windows I edited the .user.ini file in my httpdocs root folder and added the error_log line:
httpdocs/.user.ini
[PHP]
error_log=G:\PleskVhosts\xxxxxxxxxx.com\httpdocs\php_error.log
display_errors=off
log_errors=on
open_basedir="G:/PleskVhosts//xxxxxxxxx.com\;C:\Windows\Temp\"
safe_mode=off
sendmail_from=xxxxxxxxx#xxxxxxxxx.shr.prod.phx3.secureserver.net
SMTP=relay-hosting.secureserver.net
This article helped me get the absolute path
I restarted the IIS application pool and created an empty php_error.log file in my httpdocs folder, however it still never wrote anything to the log file, and continued to just give the Internal Server Error. I also tried removing all the other lines in the .user.ini file besides the error_log line, restarted, and still nothing. I also tried stopping the application pool and starting it up again, still nothing.
I double checked the phpinfo and the log_errors field was set to on, and the correct directory was set for error_log. So it is seeing the .user.ini file.
I tried calling their support but they couldn't help me.
They linked me to this article about IIS error handling. I created a web.config file and put it in the httpdocs folder as it says in that article. Now I get something different. Now the output of my page is the error that I was passing to error_log. So in other words, when I visit test.php the output on the screen says:
this is an error
Notice how the php script dies after the error? Not only should the error not be put on screen (it should be put in the php_error.log file, which is still not being written to at this point), but the php script shouldn't die afterwards unless it runs into a fatal error. I should see the "hello" from the echo and I don't.
What do I have to do to get this working properly?
My hosting plan has IIS 8 and PHP 5.4 installed.
PS. Their support basically said they cant help me any further because changing configuration files is "coding" and they dont offer coding support.
PHP needed file read write permisions

Not able to save file on server

I have created a website where you can upload pictures and the pictures get saved on a server. I had a problem before where the information gets saved in the database but the file wont get saved on the server, I then changed the file rights to 777, which allowed me to upload files to the server. Now I tried uploading a file from another computer but I get the same problem as before. Information gets saved in the database but no file gets uploaded to the server. Anyone got any idea what the problem might be?
You need to check which is the error that returns when you try to upload the file.
Check on the Apache log (or the log of the web server that you use) to see what is causing the issue.
If you are not on a live enviroment (production) or a staging environment (uat), you could enable the error reporting by enabling on the runtime configuration (php.ini) or adding the following lines on your code:
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
Here is a good example to follow to implement a file upload.

Set a different error log file for a specific PHP file

I have several websites hosted on a Windows Server 2008 machine.
I'm logging errors to disk. There are a lot of them from various scripts and plugins that I have installed that I am not interested in.
Is there a way to set a different error log for the specific PHP file that I am working on, so that I can get only the errors I'm interested in while I do development?
I tried setting
error_reporting(E_ALL);
ini_set("error_log", "c:\PHPLogs\special.log");
at the top of the file I wanted to debug, but no log file appears and I'm uncertain if this would even do what I want if it was working.
I figured it out!
In php.ini you need to set
fastcgi.logging = 1

PHP Error Logging in XAMPP

I am doing PHP development using XAMPP. I have found a file called "error_log" in the "logs" directory of my XAMPP files that seems to record every error that occurs on the server. What I'd like to be able to do is set up various error logs that only record error that occur in specific php files. Can anyone advise me on how to set this up.
You can't specify it. You can just set the error level in php.ini and add seperate log files for per project.

Running PHP on Windows with Apache2

I am new to PHP and have been trying to get a PHP application setup on Windows.
I have installed MySql5.1, Apache2.2 and PHP5.2.14 on Windows Server 2008. I can login into MySql no problem and I can run phpinfo from htdocs in apache and get the php config summary however whenever I copy in my application to htdocs and run it I get a blank page.
I have set my DirectyIndex in httpd to welcome.php but nothing .... any help troubleshooting would be great.
Make sure you turn on all error display in php.ini
error_reporting = E_ALL | E_STRICT
then see if the application still gives you a blank page. If it still does, then it maybe configuration error on apache/php. Since, you are able to display phpinfo i would say the configuration works. perhaps, there's an error on the application.

Categories