8

FastCGI doesn't want to log PHP errors properly. Well, that's not entirely true: it logs errors fine, with a little fiddling; it just won't log anything else, such as warnings.

The notorious FastCGI -> Nginx log bug isn't an issue, necessarily. Errors and warnings from php-fpm go straight to Nginx--but only if they're uncaught. That is, if set_error_handler successfully intercepts an error, no log entry is appended. This means that I can see parse errors, but that's about it.

php-fpm doesn't log PHP errors by itself (separate from nginx) without a bit of a hack. php-fpm's instance configuration file includes these two lines by default:

php_admin_value[error_log] = /mnt/log/php-fpm/default.log
php_admin_flag[log_errors] = on

I changed the error_log path, obviously. I had to add the following line to get it to actually log anything:

php_admin_value[error_reporting] = E_ALL & ~E_DEPRECATED & ~E_STRICT

Version note: the E_STRICT part is unnecessary, as I'm using PHP 5.3.27, but I plan on upgrading to 5.4 at some point. With this line, it logs errors--and only errors--to /mnt/log/php-fpm/default.log. Now, this sets error_reporting to the same value that I have set in php.ini, so something is obviously wrong here. In addition, it doesn't log caught errors: the behavior is identical to that of the nginx log. I tried using the numeric value (22527) instead, but still no luck.

I don't care in which log file the entries end up (nginx versus php-fpm), but I do need caught errors to be logged somewhere. I could resort to injecting my own error and exception handlers, but that's a bit hackish, so I'd rather avoid that.

1
  • 1
    Am I crazy in recalling that Apache didn't have this problem? Commented Aug 10, 2013 at 2:32

1 Answer 1

6

I use this directive in the pool configuration file for PHP-FPM:

catch_workers_output = yes

Sign up to request clarification or add additional context in comments.

6 Comments

I have that set, but it's still not logging the caught errors.
@Zenexer have you checked permissions on the directories and files used in logging? They should probably be owned by root; chmod 0755 on directories and chmod 0644 on files.
@Zenexer it turns out there was a PHP bug: stackoverflow.com/a/11250412/1429647
Nah, I'm on 5.5.x. Turns out vBulletin was just intercepting everything and dumping it, which I should've guessed.
This is certainly a common answer to the question, so I'm going to mark it as the answer, seeing as it ended up being something irrelevant.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.