Hello, Is it possible to get the full URLs in the logs of a Rails application? Currently I''m getting something like: Started GET "/" for 127.0.0.1 at 2011-08-27 13:13:10 +0200 but I need to get: Started GET "http://localhost:3000/" for 127.0.0.1 at 2011-08-27 13:13:10 +0200 because this is an app where the domains are important. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/JdKtp22etg4J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2011/8/27 J. Pablo Fernández <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org>> Hello, > > Is it possible to get the full URLs in the logs of a Rails application? > Currently I''m getting something like: > > > Started GET "/" for 127.0.0.1 at 2011-08-27 13:13:10 +0200 > > but I need to get: > > > Started GET "http://localhost:3000/" for 127.0.0.1 at 2011-08-27 13:13:10 > +0200 > > because this is an app where the domains are important. >Assuming you can''t, could you configure the logger to log different domains to different files? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It is possible with monkey patching by creating an initializer like this: class Rails::Rack::Logger < ActiveSupport::LogSubscriber protected def before_dispatch(env) request = ActionDispatch::Request.new(env) info "\n\nStarted #{request.request_method} \"#{request.url}\" for #{request.ip} at #{Time.now.to_default_s}" end end Would there be any interest in having something like this, configurable, in Rails? (I did patches for Rails that never managed to gather enough popularity and were ignored, I''m not wasting my time again) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/azy80IMf8-cJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2011/8/28 J. Pablo Fernández <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org>> > Would there be any interest in having something like this, configurable, in > Rails? (I did patches for Rails that never managed to gather enough > popularity and were ignored, I''m not wasting my time again) >I wouldn''t know, seems like it could be a somewhat common use case. I was just tryin'' to help ;) In any case, I don''t know about making it a patch, but you could make it into a plugin and stick it on github and rubyforge. You''d be able to use it from multiple apps easily, and if there *is* interest in it, people can use it and contribute and whatnot. Off-topic, making code like that reusable and public is never a waste of time, imo. Every once in a while I''ll get a thank-you or a feature request for some little util I wrote, pushed public, and forgot -- and it''s pretty neat. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes, I make re-usable code all the time... I released many gems and I have lot''s of github repos. The part that was a waste of time was creating a patch for Rails. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3t_3LDDADA0J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Aug 28, 9:39 am, J. Pablo Fernández <pup...-GAtDADarczzQT0dZR+AlfA@public.gmane.org> wrote:> It is possible with monkey patching by creating an initializer like this: >I''m not entirely sure what you''re trying to do, but there''s nothing stopping you creating your own log subscriber, attaching it to the relevant events and log whatever you want Fred> class Rails::Rack::Logger < ActiveSupport::LogSubscriber > protected > > def before_dispatch(env) > request = ActionDispatch::Request.new(env) > info "\n\nStarted #{request.request_method} \"#{request.url}\" for > #{request.ip} at #{Time.now.to_default_s}" > end > end > > Would there be any interest in having something like this, configurable, in > Rails? (I did patches for Rails that never managed to gather enough > popularity and were ignored, I''m not wasting my time again)-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.