1

Does PHP have built-in debugging logging like Ruby on Rails logger.info() to a development.log file?

With PHP I'd like to look "under the hood" to see what's going on... pages served, query string values, etc.

I've Googled a bunch but can't find anything.

(I'm trying to port a web app from RoR to PHP because I need more execution speed.)

1
  • Have you profiled the app to make sure that your app really is limited by the language's execution speed? Commented Dec 28, 2010 at 13:36

1 Answer 1

7

PHP has

  • error_logSends an error message to the web server's error log, a TCP port or to a file and
  • trigger_errorGenerates a user-level error/warning/notice message

which you can use to trigger and log the predefined error types, e.g.

trigger_error( "Custom Warning", E_USER_WARNING );

Third party libraries exists with

You can configure various destinations to log to. Usage is via an OO interface:

$logger->log('Informational message', Zend_Log::INFO);

and there is also the Log4J inspired

Apart from that there is XDebug and Zend Debugger. There is also a PECL extension with Advanced PHP Debugger (APD)

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

3 Comments

+1 for mentioning xdebug -- it changed the way I develop for PHP.
I'm sorry, my question wasn't clear. I'm not looking for a "log4" utility, but an automatic diagnostic.
@Pete I am not familiar with what logger does in Ruby. Sorry if my answer contains suggestions not applicable. Judging by the API docs for Logger in Ruby I'd say you are either looking for error_log or the PEAR or Zend package. XDebug and Zend Debugger are sophisticated debuggers that let you profile your code, step it through it with breakpoints and so on.

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.