Saturday, February 9, 2008

Logger in rails

By default log files are created in the log directory. But if you want to control you logs then you can specify it in the config/environment.rb file

# Include your application configuration below
#Added to include the logging capability in the code
MY_LOGGER = Logger.new("c:/logging_rail.log")
MY_LOGGER.level = Logger::DEBUG

From the code use lgger as
MY_LOGGER.info("-----------------------------");
MY_LOGGER.info("INFO: Inside function");
MY_LOGGER.info("INFO: At:"+1.hour.from_now.to_s);
MY_LOGGER.debug("DEBUG:executeQueryByID--queryid:"+params[:queryid]);

No comments: