Logging of PHP fatal errors not working

Showing 1-8 of 8 messages
Logging of PHP fatal errors not working bbf 2/3/11 1:22 AM
Cake 1.3.7

core.php:
Configure::write('debug', 0);
Configure::write('log', true);


According to this page:
http://book.cakephp.org/#!/view/1584/Error-logging
the logging of warning and fatal errors can be handled by the Cake
logs ("...Would log only warning and fatal errors.").

Warning errors are being logged fine. (I test this by including a file
that doesn't exist)

Fatal errors are not logged.  Is this an error in the docs?  Fatal
errors do show up in the log file specified in php.ini, but I can't
touch the php.ini on my shared host.


Thanks for any insight :)
Re: Logging of PHP fatal errors not working Amit Badkas 2/3/11 2:20 AM
Hi,

Think again :)

How can fatal error be logged when PHP is dead?

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com




--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Logging of PHP fatal errors not working Ryan Schmidt 2/3/11 12:07 PM
On Feb 3, 2011, at 04:20, Amit Badkas wrote:

> On Thu, Feb 3, 2011 at 2:52 PM, bbf wrote:
>
>> According to this page:
>> http://book.cakephp.org/#!/view/1584/Error-logging
>> the logging of warning and fatal errors can be handled by the Cake
>> logs ("...Would log only warning and fatal errors.").
>>
>> Warning errors are being logged fine. (I test this by including a file
>> that doesn't exist)
>>
>> Fatal errors are not logged.  Is this an error in the docs?  Fatal
>> errors do show up in the log file specified in php.ini, but I can't
>> touch the php.ini on my shared host.
>
> Think again :)
>
> How can fatal error be logged when PHP is dead?

So then you are confirming bbf's hypothesis that the documentation is incorrect here?

Re: Logging of PHP fatal errors not working Dr. Loboto 2/3/11 8:01 PM
Cake's logging settings can work only when Cake is working. If PHP
dies on parse error it just don't reach Cake setup code at all. Same
about fatal error before Cake sets own log. Etc. You better read PHP
docs before blame Cake ones.
Re: Logging of PHP fatal errors not working Ryan Schmidt 2/3/11 8:49 PM

So are you saying there are some CakePHP-related fatal errors that CakePHP would log, and other PHP-related fatal errors (parse errors, etc.) that it wouldn't?

I'm just trying to clarify your answer, since the person who started this thread pointed out that the docs say that CakePHP "Would [...] log fatal errors", with the assumption that the log file to which they'll be written is the log file about which the rest of the text in that section is written, namely the CakePHP log, while that seems to be, at least in some cases, incorrect, because of an overloading of the term "fatal error". I'm not trying to place blame anywhere, I'm simply trying to find the answer to the question that was asked.

Or are you saying that CakePHP-related errors are always written to the CakePHP log while PHP errors are always written to the PHP log? I would understand if that were the case, but don't see where the Book section on logging says this is so (though I could easily have overlooked it). If it is not there, it could be added in the form of a simple note. ("Note: Some types of errors, like PHP parse errors or other fatal errors, cannot be written to the CakePHP log and will appear in your PHP log.")


Re: Logging of PHP fatal errors not working Dr. Tarique Sani 2/3/11 9:09 PM
On Fri, Feb 4, 2011 at 10:19 AM, Ryan Schmidt
<googl...@ryandesign.com> wrote:
>
> On Feb 3, 2011, at 22:01, Dr. Loboto wrote:
>
>> Cake's logging settings can work only when Cake is working. If PHP
>> dies on parse error it just don't reach Cake setup code at all. Same
>> about fatal error before Cake sets own log. Etc. You better read PHP
>> docs before blame Cake ones.
>
> So are you saying there are some CakePHP-related fatal errors that CakePHP would log, and other PHP-related fatal errors (parse errors, etc.) that it wouldn't?

I went and saw that page, the information on the page is wrongly
represented E_WARNING is the level of error reporting which shows only
warnings and fatal errors, however if you set Configure::write('log',
E_WARNING); only warnings will be logged because fatal error will kill
PHP before it reaches CakePHP's Configure::write() method

Cheers
Tarique

--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

Re: Logging of PHP fatal errors not working Amit Badkas 2/3/11 9:23 PM
Hi,

You can log all the errors including fatal ones by using 'error_log' setting in php.ini, for example, my php.ini has

log_errors = On
error_log = /home/amit/Web/demos/php/logs/php_errors.log

Then if there is any fatal error, I get an entry in php_errors.log like

[04-Feb-2011 10:48:57] PHP Fatal error:  Call to a member function test() on a non-object in /home/amit/Web/demos/php/fatalError.php on line 3
[04-Feb-2011 10:48:57] PHP Stack trace:
[04-Feb-2011 10:48:57] PHP   1. {main}() /home/amit/Web/demos/php/fatalError.php:0

Do ensure that your webserver has the permission to write to php_errors.log

Hope that helps.

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com




--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Logging of PHP fatal errors not working euromark 2/4/11 5:22 AM
you can easily override the shutdownfunction in your bootstrap.php

register_shutdown_function('shutdownFunction');

/**
 * own shutdown function
 * 2010-10-17 ms
 */
function shutDownFunction() {
        $error = error_get_last();
        if ($error['type'] == 1 && class_exists('CakeLog')) {
                CakeLog::write('error', 'Fatal Error in '.$error['file']. ' (line '.
$error['line'].'):' . $error['message']);
        }
}


On 4 Feb., 06:23, Amit Badkas <amit.sanis...@gmail.com> wrote:
> Hi,
>
> You can log all the errors including fatal ones by using 'error_log' setting
> in php.ini, for example, my php.ini has
>
> log_errors = On
> error_log = /home/amit/Web/demos/php/logs/php_errors.log
>
> Then if there is any fatal error, I get an entry in php_errors.log like
>
> [04-Feb-2011 10:48:57] PHP Fatal error:  Call to a member function test() on
> a non-object in /home/amit/Web/demos/php/fatalError.php on line 3
> [04-Feb-2011 10:48:57] PHP Stack trace:
> [04-Feb-2011 10:48:57] PHP   1. {main}()
> /home/amit/Web/demos/php/fatalError.php:0
>
> Do ensure that your webserver has the permission to write to php_errors.log
>
> Hope that helps.
>
> Amit Badkas
>
> PHP Applications for E-Biz:http://www.sanisoft.com
>
> On Fri, Feb 4, 2011 at 10:39 AM, Dr. Tarique Sani <tariques...@gmail.com>wrote:
>
>
>
>
>
>
>
> > On Fri, Feb 4, 2011 at 10:19 AM, Ryan Schmidt
> > <google-2...@ryandesign.com> wrote:
>
> > > On Feb 3, 2011, at 22:01, Dr. Loboto wrote:
>
> > >> Cake's logging settings can work only when Cake is working. If PHP
> > >> dies on parse error it just don't reach Cake setup code at all. Same
> > >> about fatal error before Cake sets own log. Etc. You better read PHP
> > >> docs before blame Cake ones.
>
> > > So are you saying there are some CakePHP-related fatal errors that
> > CakePHP would log, and other PHP-related fatal errors (parse errors, etc.)
> > that it wouldn't?
>
> > I went and saw that page, the information on the page is wrongly
> > represented E_WARNING is the level of error reporting which shows only
> > warnings and fatal errors, however if you set Configure::write('log',
> > E_WARNING); only warnings will be logged because fatal error will kill
> > PHP before it reaches CakePHP's Configure::write() method
>
> > Cheers
> > Tarique
>
> > --
> > =============================================================
> > PHP for E-Biz:http://sanisoft.com
> > =============================================================
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+u...@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.c om>For more options, visit this group at
> >http://groups.google.com/group/cake-php