Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php error log

Status
Not open for further replies.

mwpclark

Programmer
Mar 14, 2005
59
US
How do I modify php.conf to setup an error log?

Currently /etc/httpd/conf.d/php.conf contains the following lines:

LoadModule php4_module modules/libphp4.so

#
# Cause the PHP interpreter handle files with a .php extension.
#
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 524288
</Files>

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php



phpinfo() produces the result "no value" for the php core directives

error_append_string, error_log, error_prepend_string, and error_reporting

Would it be something like this?

SetErrorLog /usr/local/apache/logs/php_error_log
SetErrorReporting on


Thanks, Mike

 
Actually, you've displayed an extension to httpd.conf...


What you put where really depends on what you want logged where.

One way is to configure PHP itself to log to a file. For that, you would edit php.ini, not php.conf. You might set:

[tt]log_errors = on
error_log = /path/to/logfile[/tt]

This will cause every PHP script to log to a particular file.

But I often have multiple sites on a single Apache server and want separate logs for each site. In httpd.conf, I would have something like:

[tt]<VirtualHost 1.2.3.4:80>
ServerName [ignore]www.somesite.com[/ignore]
DocumentRoot /home/sites/somesite/html
CustomLog /home/sites/somesite/logs/access.log common
ErrorLog /home/sites/somesite/logs/error.log

php_admin_flag log_errors on
php_admin_value error_log /home/sites/somesite/logs/php.log
</VirtualHost>[/tt]

Which puts Apache's access and error logs and PHP's error log in a separate folder for each site. This makes it a lot easier to debug a single site in a multi-hosting environment. (See for more information on php_admin_flag and php_admin_value)



Want the best answers? Ask the best questions! TANSTAAFL!
 
Along the same lines...I'll start a new thread if I don't get any answers here...

Does anyone know of a php log analyzer similar to AWStats or something?
I've got all errors turned on, I want to clean up my code and get ride of notices and everything while I go through and redesign a site. I'd like an analyzer to show me the worst offenders so I can clean up the most common errors first.

***************************************
J. Jacobs
 
Anything Free?

Otherwise I'll probably write my own code to parse through the error log, put into a mysql database and manipulate it from there.

***************************************
J. Jacobs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top