views:

44

answers:

2

I'm sure someone can explain this.

we have an application that has been in production for an year. recently we saw an increase in number of support requests for people having difficulty signing into the system. after scratching our head because we couldn't recreate the problem in development, we decided we'll switch on debug logger in production for a month. that was june 5th.

application worked fine with the above change and we were waiting.

then yesterday we noticed that the log files were getting huge so we made another change in production

config.logger = Logger.new("#{RAILS_ROOT}/log/production.log", 50, 1048576)

after this change, the application started crashing while processing a particular file. this particular line of code was

RAILS_DEFAULT_LOGGER.info "Payment Information Request: ", request.inspect

as you can see there was a comma instead of a plus sign. this piece of code was introduced in Mar.

the question is this: why did the application fail now? if changing the debug level caused the application to process this line of code it should have started failing on june 5th! why today. please someone help us. Are we missing the obvious here? if you dont have an answer, at least let us know we aren't the only one that are bonkers.

+2  A: 

When you created a new logger, it was a different class than the original.

By default, Rails uses a ActiveSupport::BufferedLogger, which will take the second argument with no exception. I believe the second argument is used as the program name. request.inspect returns a string, so it just used it as a very large name.

The new logger is just a standard Logger in Ruby core, which will raise an exception when the wrong number of arguments are passed to it.

Awgy
Nice! Thnks. I knew we were bonkers :)
so1o
A: 

Should it not be

RAILS_DEFAULT_LOGGER.info "Payment Information Request: #{request.inspect}"

Shripad K
He stated in is question that it should have been: `RAILS_DEFAULT_LOGGER.info "Payment Information Request: " + request.inspect`, which would work as well. The question is: Why did the original (with the ',') fail?
Awgy