Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a server running Lighttpd with three user's serving domains from it. Each user gets their own PHP FastCGI process for serving PHP content across all of their domains. Lighttpd allows me to write the access log files for each domain to unique log files. I also want to write PHP errors to three different log files (one for each user).

Each PHP process is reading its own php.ini (this has been verified by viewing phpinfo() output). Each php.ini specifies the log file to which it should write. For example:

error_reporting = E_ALL & ~E_NOTICE
display_errors = 0
log_errors = 1
html_errors = 0
fastcgi.logging = 1
error_log = /var/www/vhosts/example.com/logs/php_errors.log

If I set fastcgi.logging = 1 then the PHP errors, for all three users, always go to Lighttpd's error log. If I set fastcgi.logging = 0 then the PHP errors get written to the system STDERR. In this case, I can redirect the STDERR for each FastCGI process to whatever file I like, but I loose time stamping on the errors (which is less than ideal).

So, how do enable proper error logging for my PHP FastCGI processes through Lighttpd?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Lighttps supports only one error log. But it can be a program!

So try logging to your own script that splits the error log based on your own criteria. The syntax is:

server.errorlog = "|/path/to/script"
share|improve this answer
    
Would you care to elaborate on your solution? I see that Lighty supports logging to STDERR, a file, and syslog. –  jsumners Aug 17 '10 at 12:45
    
You can configure lighttpd as follows: server.errorlog = "|/path/to/script" This means that all your error lines will be piped to the stdin of that script, not written to a file. Google for "lighttpd cronolog" for discussion how this works. Unfortunately, cronolog is not a suitable program for your task, and you need to write your own script that receives log lines on stdin and dispatches them according to the user. –  AEP Aug 18 '10 at 8:06
    
Ah, okay. I will look into that. Thank you. You should roll that into your answer. I will go ahead and accept it, though, since the comment finishes it off. –  jsumners Aug 18 '10 at 23:02
    
Note, this solution will not actually work for me since Lighttpd is only up to version 1.4.19 in Debian (Lenny). Using pipes for the error log is implemented in version 1.4.23 -- redmine.lighttpd.net/issues/show/296 –  jsumners Aug 19 '10 at 13:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.