Michael Satterwhite
2006-Aug-13 22:48 UTC
[Rails] Why isn''t log working (Pragmatic Programming book)
I''m working my way through the Pragmatic Programmer book on RoR. Following their examples, I have the following code in a controller: begin @product = Product.find(params[:id]) rescue flash[:notice] = "Invalid product" logger.error("Attempt to access invalid product #{params[:id]}") redirect_to :action => :index else @cart = find_cart @cart.add_product(@product) end When I cause the error, the rescue clause is clearly trapping the error as the Invalid product error shows up, and I do get redirected back to index. The problem is that *NOTHING* shows up in log/development.log. Would someone be so kind as to tell me what I''m missing? ---Michael -- Posted via http://www.ruby-forum.com/.
Adam Greene
2006-Aug-15 04:33 UTC
[Rails] Re: Why isn''t log working (Pragmatic Programming book)
> index. The problem is that *NOTHING* shows up in log/development.log.Michael, probably a silly question, but are you sure you are writing to log/development.log and not another log (like test or productioin). Plus if you are running this as a test it won''t show up in the logs...logger is not tied into output printing for tests by default. Adam -- Posted via http://www.ruby-forum.com/.
Michael Satterwhite
2006-Aug-15 12:53 UTC
[Rails] Re: Why isn''t log working (Pragmatic Programming book)
Adam Greene wrote:>> index. The problem is that *NOTHING* shows up in log/development.log. > Michael, probably a silly question, but are you sure you are writing to > log/development.log and not another log (like test or productioin).I looked at the other logs to be sure, it''s not in any of them. To be completely honest, I''m not sure what defines it as development instead of test or production; I''m taking the book''s word that it is development.> Plus if you are running this as a test it won''t show up in the > logs...logger is not tied into output printing for tests by default.I''d love to have someone explain what makes it a test - and what is needed to activate the logger. I''m trying to learn and am very grateful for the help I''m being given. Thanks much ---Michael -- Posted via http://www.ruby-forum.com/.
Wes Garrison
2006-Aug-15 15:36 UTC
[Rails] Re: Why isn''t log working (Pragmatic Programming book)
You specify the environment when you start your web server. The default is development, so unless you said: script/server RAILS_ENV=test|production ... you''re in development Is the error printing out to the webserver console? You might also try changing it to logger.info("info message") -- Wes On 8/15/06, Michael Satterwhite <michael@weblore.com> wrote:> > Adam Greene wrote: > >> index. The problem is that *NOTHING* shows up in log/development.log. > > Michael, probably a silly question, but are you sure you are writing to > > log/development.log and not another log (like test or productioin). > > I looked at the other logs to be sure, it''s not in any of them. To be > completely honest, I''m not sure what defines it as development instead > of test or production; I''m taking the book''s word that it is > development. > > > > Plus if you are running this as a test it won''t show up in the > > logs...logger is not tied into output printing for tests by default. > > I''d love to have someone explain what makes it a test - and what is > needed to activate the logger. I''m trying to learn and am very grateful > for the help I''m being given. > > Thanks much > ---Michael > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -- Wes -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060815/e2e1281f/attachment.html