Rails not writing to development log - ruby-on-rails

My Rails app (version 4.0.3) is not logging anything in dev. My development.log (as well as test.log) were last touched on 12/12/2013, which is the day I created the project. So logging has evidently never worked in dev or test. (Production seems to be working just fine, FWIW.)
It doesn't seem to be a permissions issue; my log directory is recursively 777'd.
I've restarted my server after ensuring the permissions are good, so it's not that.
Any ideas?

Related

Rails stopped logging

My rails app running in development environment stopped logging all of a sudden and I am not able to figure out why.
I tried logging into a new file by doing
config.logger = Logger.new('log/temp.log')
config.log_level = :debug
But still no luck. The new file temp.log was created but nothing is logged in the file. The thing is this happens on my development server running nginx (I run my rails app using "rails s -d" on this server). The exact same files, when I run on my local machine (my own computer), logging works fine.
So I feel the reason logging is not working is because of something specific to the server, but then I didn't do anything much on the server (e.g. I didn't install new gems, etc.) Logging has been working fine until few days ago.
When I go to rails console
rails c
> Rails.logger.debug "hello"
=> true
I do get "hello" logged into 'log/temp.log' specified above in config file.
I think permission on log directory or file is ok. What else could be wrong?
I believe it's a locking issue which you might be able to solve after removing the call to the logger which causes this.
I ran into this issue with Redmine 1.x,
I found newrelic_rpm entry in the production.log, saying it didn't run, and 1 line of a Redmine plugin init.
After removing both, newrelic_rpm from the environment.rb (config.gem line), and the plugin logger init message, the logging facility appears to be restored and log entries are appearing again.

No log messages in production.log

I wrote a demo HelloWorld Rails app and tested it with WEBrick (it doesn't even use a DB, it's just a controller which prints "hello world"). Then I tried to deploy it to a local Apache powered with Passenger. In fact this test is just to get Passenger working (it's my first deploy on Apache). Now I'm not even sure that Passenger works, but I don't get any error on the Apache side.
When I fire http://rails.test/ the browser shows the Rails 500 error page - so I assume that Passenger works. I want to investigate the logs, but it happens that production.log is empty! I don't think it's a permission problem, because if I delete the file, it is recreated when I reload the page. I tried to change the log level in conf/environments/production.rb, tried to manually write to log file with Rails console production and
Rails.logger.error('asdf')
it returns true but nothing gets written to production.log. The path (obtained per Rails.logger.inspect) is correct, and I remark that the file is recreated if I manually remove it. How can I know what's going on?
(I already checked the Apache logs, plus I set the highest debug level for Passenger but it seems a Rails problem, so is not logged by the server)
Assuming you're running Rails 3.2.1, this is a bug. It was patched in 3.2.2.
If you can't upgrade to 3.2.2 for any reason, this comment on GitHub has a workaround:
# config/initializers/patch_rails_production_logging.rb
Rails.logger.instance_variable_get(:#logger).instance_variable_get(:#log_dest).sync = true if Rails.logger
Setting this works on Rails 3.2.11:
Rails.logger = ActiveSupport::BufferedLogger.new(Rails.root.join("log","production.log"))

rails app - sudden 403 after pull - how do I start to debug?

I'm been working on a rails 3.1 app with one other dev.
I've just pulled some of his recent changes, using git. And am now getting a 403 on any page I try to visit.
You don't have permission to access / on this server.
I'm running the site locally through passenger.
Oddly, when I start the app using rails' internal server. I can visit the site at http://0.0.0.0:3000
Looking at the changes in this recent pull, the only files have changed are some javascripts, some html the application.rb, routes.rb and a rake file.
How do I debug this, I'm a bit lost on where to start?
EDIT:
If I roll back to an earlier version the site works, through passenger. Which leads me to believe the problem is within the rails app, rather than an Apache error. Or it could be a permissions thing, can git change file permissions in this way?
IMHO this is a configuration error in Apache or wrong directory layouts. Make sure that the passenger_base_uri still points to the public folder inside your rails project and that there are no hidden .htaccess files which block access. Also verify that your sym-links are correct (if there are any). Also check your Apache error log.
Start by launching your console to see if rails and your app can be loaded.
In your application root directory type :
rails console

Mongrel not detecting changes in Rails classes?

I have a Rails app installed on a Slicehost server running Apache 2 and Ubuntu LTC 10.04. Things have worked beautifully up until now: I edit a file, do a quick mongrel_rails cluster::restart, and the changes are reflected in production. However, suddenly this process has broken down.
For example, I have a class called Master located in /lib/master.rb. I added a new method to this class that simply runs puts "it works!", then restarted the mongrel cluster. Looking at the production logs, the server throws an error and thinks this method doesn't exist. When I go to the console using ruby script/console production, however, I can use this new method perfectly. I even tried deleting the file containing entire Master class. Once again, the production thought it was still there, but the production console correctly recognized it was missing.
Any ideas? How can the production environment detect a class that doesn't even exist anymore?
Funny, I spend 2 hours debugging this, then post to StackOverflow and figure it out in 20 minutes.
The problem is that I needed to also restart my background jobs as well. They were running the old version of the classes stored in /lib. It's interesting that this problem has never snagged me before.

Weird Facebooker Plugin & Pushion Passenger ModRails Production Error

I have an application (Rails 2.3.5) that I'm deploying to production Linux/Apache server using the latest Phushion Passenger/Apache Module 2.2.11 version. After deploying my original application, it returns a 500 error with no logging to production log.
So I created a minimal test rails application, with some active record calls to the database to print out a list of objects to the home controller/my index page. I also cleared out all plugins. That works fine in the production environment. Then I one by one introduced each plugin that I'm using one at a time.
Every plugin works fine EXCEPT facebooker. Every time I load the facebooker plugin into my app/vendor/plugins directory (via script git etc) my test application break (500 error - no error logging). Everytime I remove the facebooker plugin my test application works.
Has anyone seen this before/ have any solutions? I saw this solution but didn't see it in the facebooker code.
Did you add Facebook credentials for production environment?

Resources