You are not logged in.

#1 2008-06-27 14:05:08

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

PHP not logging via syslog-ng

Hi all,

Having a problem with PHP on Apache and not being able to get logs out. My php.ini is logging to syslog:

root ~ # grep '^error_log' /etc/php/php.ini 
error_log = syslog
root ~ #

And syslog-ng is setup as so:

root ~ # grep php /etc/syslog-ng.conf
destination php        { file("/var/log/php.log"); };
filter f_php        { program("^php"); };
log { source(src); filter(f_php);    destination(php); };
root ~ #

I've also tried replacing program("^php"); with match("php"); but to no avail sad

I have a test page on my webserver which should throw an error:
root ~ # cat /home/fukawi2/public_html/test.php

<?php
echo "Moo"
?>

(No ; to end the echo statement)
When I access this page via my web browser, it prints "Moo", but no error is written to /var/log/php.log

I restart syslog-ng after any change I make to the conf file.
What am I doing wrong?

Offline

#2 2008-06-27 14:44:51

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: PHP not logging via syslog-ng

What about error_reporting level and log_errors = On ?

Offline

#3 2008-06-27 14:51:05

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: PHP not logging via syslog-ng

root ~ # egrep '^error_reporting |^log_errors ' /etc/php/php.ini 
error_reporting  =  E_ALL
log_errors = On
root ~ #

Offline

#4 2008-06-27 15:17:06

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: PHP not logging via syslog-ng

Can you log to a file without going through syslog i.e. error_log = filename?   If so, then I guess the problem is with syslog...

Offline

#5 2008-06-28 07:17:27

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: PHP not logging via syslog-ng

I actually suspected it was syslog-ng, but it appears not...

root ~ # grep "^error_log" /etc/php/php.ini 
error_log = /tmp/php.log
root ~ # touch /tmp/php.log
root ~ # chmod 777 /tmp/php.log
root ~ # /etc/rc.d/httpd restart
:: Stopping HTTP Daemon                                                                                                                                                                             [DONE] 
:: Starting HTTP Daemon                                                                                                                                                                             [DONE] 
root ~ #

I then accessed my test error page, but....

root ~ # cat /tmp/php.log 
root ~ #

Offline

#6 2008-07-02 00:38:17

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: PHP not logging via syslog-ng

El bumpo... Anyone? sad

Offline

#7 2008-07-02 01:37:17

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: PHP not logging via syslog-ng

I am puzzled.  What if you set log_error=off so that errors are displayd on the web page instead...:/

Offline

#8 2008-07-02 01:41:42

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: PHP not logging via syslog-ng

root ~ # grep '^log_errors' /etc/php/php.ini 
log_errors = Off
log_errors_max_len = 1024
root ~ # /etc/rc.d/httpd restart
:: Stopping HTTP Daemon                                                  [DONE] 
:: Starting HTTP Daemon                                                  [DONE]

www/~fukawi2/test.php

Moo

sad

Offline

#9 2008-07-02 01:47:33

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: PHP not logging via syslog-ng

What about setting display_errors = On ( that should show them on the browser)
And throw in a display_startup_errors = On while we are there....

Offline

#10 2008-07-02 02:07:07

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: PHP not logging via syslog-ng

display_errors was already on, and display_startup_errors had no effect. Same as my last post neutral

Offline

#11 2008-09-09 18:35:24

bitpal
Member
From: Berlin, Germany
Registered: 2008-02-03
Posts: 46
Website

Re: PHP not logging via syslog-ng

did you ever get this to work?

I had a similar problem and found that changing error_log to a local file in php.ini did the trick.

By the way, your test file didn't show an error on my system either, just said 'Moo'. But calling a nonexistent function logged the error.

Offline

#12 2008-09-09 22:16:28

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: PHP not logging via syslog-ng

Yes smile
http://www.linuxquestions.org/questions … ost3201264

Once I fixed my error-generating test, it logs properly now smile

Offline

Board footer

Powered by FluxBB