If you're developing using ActiveResource, you should to add this line to your environment.rb:That will write all your resource requests to the log as well, a useful thing.
ActiveResource::Base.logger = ActiveRecord::Base.logger
Saturday, March 14, 2009
ActiveResource logging tip
Posted by
Sidu
at
02:01
Tags:
activeresource
,
howto
,
rails
Subscribe to:
Post Comments
(Atom)
Tag Cloud
- .net
- 2010
- activ
- activeresource
- agile
- ajax
- analysis
- announcement
- anti-pattern
- architecture
- bangalore
- bangpypers
- barcamp
- barcampbangalore4
- barcampbangalore5
- bcb4
- blogger
- book review verdict:read
- books
- browser
- brug
- bug
- c42
- call
- cc.rb
- ci
- conference
- content repository
- continuous integration
- cool
- css
- cycle
- darkness
- DCB1
- dcb2
- deployment
- devcampbangalore
- digg
- dining table
- django
- dragdrop
- dzone
- enterprise
- event
- evolving
- feedburner
- feedflare
- feedflareunit
- fun
- functional programming
- GI
- goldberg
- gotcha
- gwt
- hack
- hackdayindia
- hiring
- howto
- humour
- ide
- india
- innovative
- intellij
- interview
- intro
- irc
- jackrabbit
- java
- javaone
- javascript
- jcr
- jquery
- jruby
- JSNI
- junction
- leisure
- links
- literature
- lucene
- mac
- metaprogramming
- methodology
- microsoft
- mingle
- mochikit
- mongrel
- musings
- mvc
- nasscom
- news
- noob
- offshore
- OOP
- opinion
- oss
- osx
- performance
- photo
- plugin
- practices
- programming
- prototype
- python
- quality
- quirks
- rails
- rant
- rdt
- recruiting
- recruitment
- refactoring
- registry
- release
- resharper
- REST
- ruby
- rubyconf
- rubyconf2011
- scala
- search
- security
- skills
- spawn
- startup
- symlinks
- sysinternals
- tdd
- testing
- thoughtworks
- tibco
- tomcat
- tool
- training
- tw
- twb
- tweak
- unconference
- undernet
- utf8
- versioning
- video
- web
- windows
- wrest
- xp
- YUI








9 comments:
Thanks man...big help. Much appreciated.
Thank you!! But I had to put this line inside config/initializers/new_rails_defaults.rb
Thanks a million!
Tip for totally clueless people like me: it has to be put outside of the "Rails::Initializer.run do |config| ... end" section (at least I got a scary error when I put it in there).
I know next to nothing about Ruby and even less about Rails, but I'm trying to design our company's web-service API to be as ActiveResource-friendly as possible. In my book that means I have to develop at least a simple Rails app that exercises all of the API. Combined with my extreme ignorance leads to GSDD (Google-Search Driven Development), which is only possible because of wonderful people like you who put this information where Google can index it.
Again, thanks a million times!
@DerHeiligste That's probably because inside ActiveRecord::Base.loggers was still nil inside of the config block.
Feel free to ping me should you need any further assistance - I've spent more time than I care to think about alternately developing POX resources and wrestling with ActiveResource, so hopefully I can save you some effort.
I have a file that I put in the initializers directory to print the AR queries to STDOUT in script/console. You could do the same with area.
The script is:
# make AR output go to STDOUT in script/console
if "irb" == $0
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
Any way to have the Active Resource loggers also log the http headers going out?
Yes, but you'd have to monkey patch ActiveResource#connection.
I've already patched connection to allow a custom header value but I don't see how to get it to log...
class ActiveResource::Connection
alias :static_default_header :default_header
def set_header(key, value)
default_header.update(key => value)
end
end
where does ActiveResource log to? Or rather, for a rails application in production mode, where does ActiveRecord.logger write to? (production.log?)
I can seem to find ActiveResource calls in the log file even after this change in environment.rb
thanks
Post a Comment