Alexander Farber
2010-Jul-30 22:47 UTC
[CentOS] Redirecting PHP error messages into a log file
Hello, I'm using CentOS release 5.5 x86_64 with the stock php-5.1.6-27.el5 and would like to redirect PHP messages into /var/log/httpd/php_log First I tried adding that file name to /etc/php.ini: error_log = "/var/log/httpd/php_log" and restarted httpd, but the file didn't appear. I've touched it and changed owner to apache.apache, but that didn't help. Then I've changed that line to error_log = syslog and now I get the messages in /var/log/messages: Jul 29 21:29:24 hXXX httpd: PHP Notice: Undefined index: REMOTE_ADDR in /var/www/html/odnoklassniki/index.php on line 44 Jul 29 21:29:45 hXXX httpd: PHP Parse error: syntax error, unexpected '[' in /var/www/html/odnoklassniki/index.php on line 44 I still would like to move those message to a separate file though, so I've added the following line to /etc/syslog.conf and reloaded syslogd service: httpd.* /var/log/httpd/php_log but the file is still empty. Any hints please? Thank you Alex -- http://preferans.de
Jason Pyeron
2010-Jul-30 22:48 UTC
[CentOS] Redirecting PHP error messages into a log file
> -----Original Message----- > From: centos-bounces at centos.org > [mailto:centos-bounces at centos.org] On Behalf Of Alexander Farber > Sent: Friday, July 30, 2010 18:47 > To: CentOS mailing list > Subject: [CentOS] Redirecting PHP error messages into a log file > > Hello, > > I'm using CentOS release 5.5 x86_64 with the stock > php-5.1.6-27.el5 and would like to redirect PHP messages into > /var/log/httpd/php_log > > First I tried adding that file name to /etc/php.ini: > error_log = "/var/log/httpd/php_log" > and restarted httpd, but the file didn't appear. > I've touched it and changed owner to apache.apache, but that > didn't help. > > Then I've changed that line to error_log = syslog and now I > get the messages in /var/log/messages: > > Jul 29 21:29:24 hXXX httpd: PHP Notice: > Undefined index: REMOTE_ADDR in > /var/www/html/odnoklassniki/index.php on line 44 Jul 29 > 21:29:45 hXXX httpd: PHP Parse error: > syntax error, unexpected '[' in > /var/www/html/odnoklassniki/index.php on line 44 > > I still would like to move those message to a separate file > though, so I've added the following line to /etc/syslog.conf > and reloaded syslogd service: > > httpd.* > /var/log/httpd/php_log > > but the file is still empty. Any hints please?Selinux issue?> > Thank you > Alex > > -- > http://preferans.de > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - - Jason Pyeron PD Inc. http://www.pdinc.us - - Principal Consultant 10 West 24th Street #100 - - +1 (443) 269-1555 x333 Baltimore, Maryland 21218 - - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- This message is copyright PD Inc, subject to license 20080407P00.
Keith Roberts
2010-Jul-31 12:48 UTC
[CentOS] Redirecting PHP error messages into a log file
On Sat, 31 Jul 2010, Alexander Farber wrote:> To: CentOS mailing list <centos at centos.org> > From: Alexander Farber <alexander.farber at gmail.com> > Subject: [CentOS] Redirecting PHP error messages into a log file > > Hello, > > I'm using CentOS release 5.5 x86_64 with the stock php-5.1.6-27.el5 > and would like to redirect PHP messages into /var/log/httpd/php_log > > First I tried adding that file name to /etc/php.ini: > error_log = "/var/log/httpd/php_log" > and restarted httpd, but the file didn't appear. > I've touched it and changed owner to apache.apache, > but that didn't help.It's a bit tricky setting up PHP error logging to a seperate file. This works for me on 32bit, Centos 5.5 and Fedora 12, and previous Fedora versions. Here are my settings: SELinux disabled at boot time. /etc/php.ini file: ; Besides displaying errors, PHP can also log errors to locations such as a ; server-specific log, STDERR, or a location specified by the error_log ; directive found below. While errors should not be displayed on productions ; servers they should still be monitored and logging is a great way to do that. ; Default Value: Off ; Development Value: On ; Production Value: On ; http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors log_errors = ON ; Set maximum length of log_errors. In error_log information about the source is ; added. The default is 1024 and 0 allows to not apply any maximum length at all. ; http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors-max-len log_errors_max_len = 1024 ; Do not log repeated messages. Repeated errors must occur in same file on same ; line unless ignore_repeated_source is set true. ; http://www.php.net/manual/en/errorfunc.configuration.php#ini.ignore-repeated-errors ignore_repeated_errors = Off ; Ignore source of message when ignoring repeated messages. When this setting ; is On you will not log errors with repeated messages from different files or ; source lines. ; http://www.php.net/manual/en/errorfunc.configuration.php#ini.ignore-repeated-source ignore_repeated_source = Off ; Log errors to specified file. PHP's default behavior is to leave this value ; empty. ; http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log ; Log errors to syslog or specified file (Event Log on NT, not valid in Windows 95). ;error_log = syslog error_log = /var/log/apache/php_error_log The file permissions for my php error log are: [root at karsites apache]# ls -l php* -rw-rw-rw- 1 root root 91472 2010-07-31 08:00 php_error_log -rw-rw-rw- 1 root root 0 2008-05-29 13:30 php_error_log.skel -rw-rw-rw- 1 root root 0 2008-05-29 13:30 php_mail_log [root at karsites apache]# If the PHP error log file is not set up correctly, then PHP will just output the errors to the apache error log file instead. HTH Keith Roberts
Kai Schaetzl
2011-Jun-29 22:01 UTC
[CentOS] Redirecting PHP error messages into a log file
Alexander Farber wrote on Sat, 31 Jul 2010 00:47:05 +0200:> First I tried adding that file name to /etc/php.ini: > error_log = "/var/log/httpd/php_log"I can assure you that you don't have to go the syslog way. Logging to a php errorlog file of your choice works just fine. Check the file permissions and check for selinux warnings. Kai