How to add logging to CakePHP applications
Note that Pear’s Logging package is a lot more flexible, so I recommend you use that instead of CakePHP’s built-in logging.
Use this code to add a debug message to the CakePHP debug log:
1 $this->log("Upload action accessed", LOG_DEBUG);
Note that using something other than LOG _DEBUG will log the message as an error.
Run the code once and you should be able to see the message in $CAKE_APP/tmp/logs/debug.log.
Fixing "config.breakpoint_server has been deprecated and has no effect" when using Rails Edge
You might get this error if you’re using Rails Edge: config.breakpoint_server has been deprecated and has no effect:
To fix the error we need to remove the following from config/environments/development.rb:
1 config.breakpoint_server = true
Next install ruby-debug:
1 gem install ruby-debug
Then add this to the end of config/environments/development.rb:
1 require 'ruby-debug'
Next, start your server, and the error should be gone…
To debug your code just add a call to debugger:
1 class MySillySpace ... 2 def create 3 debugger # add this line 4 end
Now when you access the URL with your browser you’ll have access to the debugger from the console window.
To learn how to use ruby-debug, read this tutorial written by the ruby-debug author.
Enable remote debugging in weblogic
Sometimes it’s necessary to debug because you can’t write a test for it (e.g a legacy system). Just add the following parameters to the server startup and connect your preferred debugger into port 1044 (or whatever you choose the port to be). Works in weblogic, but should work in JBoss and other java based application servers too.
1 -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044