PHP Error Logging in XAMPP - php

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.

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

How do I make PHP files automatically write to a file?

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.

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

Changing the location of the PHP error log file

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.

Symfony project is not work on local pc

I have this trouble: i copy symfony project files on my pc, after that change paths and db settings, and it still not working, even dont tell about errors! Maybe there is some specific actions for setting up symhony on another server?
Almost the same problem How to configure symfony project in local server? but when i try execute "php symfony" it prints "no such file or directory"
There are no any php errors at all.
Using Fedora 15 OS, and apache. php work in command line, symfony is not working. I tried to find out what is happening - inside Controller.class some error, when it use processObjects method, it take 11 objects, and after first of them (header.object.php) it stops.
The white screen generally means symfony can't write to cache and/or log dir, check on apache error logs to see details.
if 'php symfony' on command line throws no such file or directory could mean php is not in your system path.
Please add more information to get answers
myabe, as said below is a permission problem of the caché and log files. Check if they are writable. Good Luck!

Categories