20

I am sysadmin trying to debug a Drupal site. In my server logs I can see Drupal making the same requests again and again to our Solr instance until PHP eventually runs out memory, and Apache returns a 500 error.

How can I configure Drupal to log a stack trace somewhere on the disk?

15

You can use the Devel module, and select one of the "Krumo Backtrace" options it provides in its configuration page at admin/config/development/devel.

Krumo Backtrace

Make sure to visit admin/config/development/logging and select "Errors and Warnings" or "All Messages". If you have the Syslog module, or any other logging module enabled, you may need to disable it and enable the Dblog module.

backtrace config

  • 6
    I find this method fails to give the krumo backtrace for certain exceptions, e.g. accessing a non-existant property on an EntityMetadataWrapper object. – artfulrobot May 29 '15 at 18:07
  • 3
    For EntityMetadataWrapper errors go to the line in the reported error and insert ddebug_backtrace(); just before that line. Don't forget to remove that of course! – Duncanmoo Oct 1 '15 at 9:58
  • Are these messages logged somewhere or is it possible to make them go into a log? It is kind of useless on production otherwise. – Hjulle May 14 at 14:44
1

in your drupal system in modules section under core modules their is syslog module to store log on the disk. hope it help what your looking for.

  • 1
    This does not work on fatal errors (such as out of memory errors), unfortunately. – stefgosselin Aug 31 '12 at 3:05
0

For Drupal 7 and 8, the module inspect is great for backtraces.

It can add them to files or the log in the Drupal database rather than showing them, which is useful in cases where Krumo backtrace, ddebug_backtrace() and other solutions that create direct on-screen output fail. That is the case for errors and exceptions happening before rendering output started.

The admin backend config area for inspect contains a nice quick reference for its usage in code.

  • 2
    I poked around in the inspect docs, but I didn't see a way use it to generate a stack trace upon error. Is that something it can do? – Ken Williams May 30 '17 at 3:45
0

The Trace module worked much better for my situation.

This is a sysadmin & developer tool that adds extensive tracing facilities for Drupal hook invocations, database queries and PHP errors.

Some features provided by version 1.0 this module:

  • Outputs trace messages to a file or the syslog (on Unix platforms).
  • Traces Drupal hook invocations with an optional filter and stack trace.
  • Traces PHP warnings and errors with an optional full stack trace.
  • Traces SQL database queries with optional filtering by query type.
  • Trace output includes microsecond-level timing information.
  • Stack traces include the function's passed arguments in PHP syntax.
  • Optional debug output includes PHP superglobals and HTTP headers.
  • Defines a hook allowing other modules to extend the trace output targets.
  • 1
    Now this module is no longer in development and seemingly no D7 version is available … :( – tanius Mar 13 '16 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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