How can I change php-fpm.conf (or php.ini) so all errors/ warnings/ ... are written to stderr (or alternatively to stdout)?
I run php5-fpm
with daemonize = no
and want to see all errors in my terminal.
The solution is to set ...
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
catch_workers_output = yes
Yes, it is possible without messing with the .ini config.
Use a Unix descriptor, like one of those example:
php myscript.php 2> errors.log
Or by using a hashbang, file must then be set as executable:
./myscript 2> errors.log
From there all errors will be logged.
To write only in errors.log
, use fwrite
anywhere in your php script:
<?php
fwrite(STDERR, "Some debug infos\n");
Appear only in errors.log
. Useful when writing fast refreshing scripts.
Notice that all errors are erased when restarting.
To watch for errors, use tail -f
or watch cat
watch cat errors.log
I do not think that you can achieve that, at least in the way I am understanting it from your question.
I wiil propose you a work around to view php through terminal in real time
Step 1 - write all error to a file
change your php.ini file to write every error to file /logs/phpLogs
Step 2 - via error 'real time' using tail
From your command line run the tail command
tail -f /logs/phpLogs
Step 3 - Optionally use error_log
User the php error_log command
error_log(print_r(debug_backtrace(), true ))
EDIT : (just found it) My anwser is similar to that How to log errors and warnings into a file