I've hosted websites with companies like hostgator before where if a PHP error was thrown it would write to a file in the directory of the site where the error was made. The file would be called error.log or something like that.
I would like to set this up on my local machine, does anyone know if this possible with an out of the box setup of XAMPP?
PHP Runtime Configuration
log_errors boolean.
Tells whether script error messages should be logged to the server's error log or error_log. This option is thus server-specific.
You can probably find the php.ini in the php subfolder of the xampp installation.
Related
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
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
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.
Good morning. I'm having a major issue with my phpBB installation.
I've transfered it to my computer to develop some plugins, so i'm running it on localhost, but, i've created a vHost with the exact same domain he is running online, so, i don't need to change the cookies configuration, and the database connection information is correct already.
Regard all of that, i'm getting a 500 internal server error, which displays no error on the screen nor the logs from apache and php.
I have error reporting on php as E_ALL also. What could be possible causing this, and what the solution might be?
Thanks in advance, Jorge Ferrari.
If you're getting nothing in the Apache / PHP error logs, then it's more likely to be a server configuration issue. I would suspect the problem is in a file called .htaccess in the phpBB folder. It can be used to customize the configuration in various ways, including things like setting up redirects and URL rewriting.
If the htaccess file tries to use an Apache feature which isn't available on the server, then it can generate a 500 error. You can test this by temporarily removing the file, and seeing if the website works at all (albeit possibly with some glitches).
If you've confirmed that it's the source of the problem, then ideally you'll need to enable the missing feature in the server's configuration (or possibly update the Apache installation). Alternatively, you can delete or comment-out the problematic bits of the htaccess file.
Either way, it sounds more like a webserver admin issue than programming. You might have more luck asking on the phpBB forums, or on a different Stack Exchange Q&A site (possibly Server Fault?).
Check whether you have Rewrite module enabled?(most of the this will be the reason)
In httpd.conf and uncomment
LoadModule rewrite_module modules/mod_rewrite.so
If you try to use module which is not loaded you will get 500 internal server error.
Check your modules used in .htaccess file and check httpd.conf whether used modules are loaded
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.