Debugging Rails

You can always debug your application and get it back on the rails if ever it something goes wrong. You have to check the application log files. See to it that “tail –f” commands are running on the server.log and development.log. Rails will then show debugging and runtime information to these files and debugging information will also be displayed in the browser on requests from

Using the Ruby logger class from inside your controllers, you can also log your own messages directly into the log file from your code like:

class ReportController < ActionController::Base

def destroy

@report = Report.find(params[:id])


#Debug Log file“#{} Destroyed Report ID ##{}!”)



These are the available log levels, :debug, :info, :warn, :error, and :fatal, corresponding to the log level numbers from 0 up to 4 respectively.



The DEBUG level designates fine-grained informational events that are most useful to debug an application.

The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.


The WARN level designates potentially harmful situations.


The ERROR level designates error events that might still allow the application to continue running.


The FATAL level designates very severe error events that would presumably lead the application to abort.

To write in the current log use the logger.(debug|info|warn|error|fatal) method from within a controller, model or mailer.

The default Rails log level is info in production mode and debug in development and test mode.

Permanent link to this article:

Leave a Reply

Your email address will not be published.