php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52761 include backtrace in web server log on fatal error
Submitted: 2010-09-01 15:21 UTC Modified: 2012-01-10 19:09 UTC
From: freeman3 at centrum dot cz Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 5.3.3 OS: opensuse
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: freeman3 at centrum dot cz
New email:
PHP Version: OS:

 

 [2010-09-01 15:21 UTC] freeman3 at centrum dot cz
Description:
------------
is it possible to include debug backtrace in the error log when some serious error occurs? Error like "PHP Fatal error:  Call to a member function getColumns() on a non-object in ../core/entity_core.php on line 230" is quite useless because I don't know from where it was called.

Expected result:
----------------
Include debug backtrace in the error log

Actual result:
--------------
Now only the last line of backtrace is present

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-01 18:11 UTC] giorgio dot liscio at email dot it
i think this will marked as "wont fix"

full backtrace will be too long to log..
if you want you can implement your error logger in user space
 [2010-09-01 19:01 UTC] freeman3 at centrum dot cz
Too long? I mean log only for fatal error and such. I happens only when developing application usually, few times a day. It would be few extra lines only. Access log has several GB usually so I think few lines doesn't matter. I think many developers would be grateful because this can save much time.
I have tried something with shutdown handler but it didn't work for me. If you have a code that returns backtrace when fatal error occurs, I would be grateful.
 [2010-09-01 21:30 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-09-01 21:30 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You can install xdebug on your development server to get this feature. http://xdebug.org
 [2010-09-01 22:52 UTC] freeman3 at centrum dot cz
I know it's not a bug. That's why I marked it as feature request (where else 
should I post feature request?!?). And I didn't find such option in php manual. I 
wanted only extend the error message in the log, I don't want to install xdebug 
on production server...
I still think it would be a good idea.
 [2010-11-04 20:11 UTC] robin at robindaugherty dot net
"if you want you can implement your error logger in user space"

I don't believe it's possible to implement an error logger for fatal errors in user space. I see this as a huge problem. I develop and run a 
large site using PHP. I have a user-space handler for all other errors, notices, etc., but fatal errors are uncatchable and the log entry is 
usually missing enough information to track down the problem. For example:

Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in [...]/ErrorHandler.php on line 785

I've tried to find a way to detect this, and having the backtrace would help. This particular code is called to render hundreds of variable 
on the page before the fatal one (which is apparently a non-fatal error or notice occurring inside of ob_gzhandler). I just need the call 
stack that exists when the error occurs.

This is especially true of production sites, where I try to get enough information to at least reproduce issues. I get backtraces and 
context information for non-fatal errors, but the fatal errors are more important.
 [2011-02-20 21:31 UTC] freeman3 at centrum dot cz
I totally agree with robin, i still don't get why it's marked as bogus. How do you trace fatal errors?
I you use a framework and an error occurs in a framework code file (like modelAbstract.php, which almost every other file uses), the error message like fatal error occured in modelAbstract.php is totally useless
 [2012-01-10 16:19 UTC] walovaton at yahoo dot com dot mx
If you install xdebug you will get exactly what you want although it will make the execution somewhat slower (acceptable in development but maybe not in production).

What I would like to see is a way to get a backtrace of the current point of execution in the PHP code in a similar way you get it from Java when you kill -3 the process ID.  It doesn't die, instead it gives you a backtrace of what it's doing at that moment.  Is there any way to do this?? I guess I should file a new enhancement request.
 [2012-01-10 19:09 UTC] freeman3 at centrum dot cz
Still no response?
this feature would be very useful. I can't use xdebug in production environment...
is this some zend server only feature?
 [2012-06-07 09:31 UTC] jl235 at kent dot ac dot uk
It is currently *impossible* to get a backtrace in pure PHP.

Fatal errors by their very definition, are pretty damn serious. A backtrace makes them easier to debug.

If not add a stack trace to the log, at least allow it to be recorded, and retrieved by user code in 'register_shutdown_function'. Then users can chose to log it themselves.
 [2012-07-24 11:42 UTC] willem at stuursma dot name
You can also use the APM extension, which will log all errors with their requests 
and stack traces to a database (including E_ERRORs). Still, should be fixed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 11:01:30 2024 UTC