Suddenly my Rails 4.2 app is writing nothing to development.log.
Absolutely nothing!
I have tried checking the correct environment is being used, restarting the server, checking for gems that might interact with logger, checking permissions, logger.flush, and rake log:clean.
The log file is now completely empty, and nothing is being written.
Running rails s gives:
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-03-14 18:49:57] INFO WEBrick 1.3.1
[2015-03-14 18:49:57] INFO ruby 2.1.5 (2014-11-13) [x86_64-darwin14.0]
[2015-03-14 18:49:57] INFO WEBrick::HTTPServer#start: pid=3963 port=3000
There are quite a few similar questions on Stackoverflow, but none provide an answer that has worked in my case.
I have no idea what would cause this or how to systematically debug.
What steps should I take?
OK, after much going round in circles, I finally found the culprit.
The rails_12factor is apparently overwriting config.logger.
See: https://github.com/heroku/rails_stdout_logging/blob/master/lib/rails_stdout_logging/rails3.rb#L7
I removed this gem from the development environment (I really only need it in the deployed environment) and everything is now working.
To put a gem in production only, it needs to be in a gem environment group like this:
# This is override development.log output and should only go in production.
group :production do
gem 'rails_12factor'
end
Thanks #maxd for helping to get me thinking in the right direction.
I think your problem can be caused by the following things:
You set to high log level. Check your application.rb and environments\*.rb files:
# Set to :debug to see everything in the log.
config.log_level = :error
You set custom logging. Check your application.rb, environments/*.rb and all files in initializers/*.rb:
# Use a different logger for distributed setups.
config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
These two steps should help you to investigate problem and fix it.
Add the following line to config/environments/development.rb
config.log_level = :debug
restart server
If in AWS (or similar) you have to make sure that your log directory has write access.
Related
I have 2 envs: test, and production
in both I have the following under enviroments/*.rb:
config.logger = LogStashLogger.new(port: 5228)
Problem is , that only on test env i have Rails.logger pointing to this logger and working, and in production env, the Rails.logger is still STDOUT.
I looked and searched for another override, but found nothing.
I even tried to put it on the config/enviroment.rb, but without any luck. Production insists on being STDOUT...
Is this related to nginx/passenger in any way?
Please assist
Tnx!
it was rails_12factor in my gemfile (Heroku's gem) that includes
rails_stdout_logging !!!!!
i removed it completely and it solved my problem.
I have set up a rails 4 server on Ubuntu 12.04 using Capistrano, Nginx, Passenger, Postgres, Redis/Resque
Everything is working great, except that the production.log file is always empty.
I have tried a variety of configuration changes in production.rb to no avail.
It's definitely not a permissions issue, as the permissions on both the log dir and each of the logs are wide open (777)
Can anyone hep me figure out how to get basic logging working?
The culprit was Heroku's rails_12factor gem
Removing that gem from the Gemfile, now the logs are working as expected.
# group :production do
# gem 'rails_12factor'
# end
To clarify, the rails_12factor gem was responsible, but that's only because it includes rails_stdout_logging, which is the real culprit, however, due to it's intended behavior to "ensure that your logs will be sent to standard out."
Check with the log levels in production.rb file, config.log_level = :debug will display it's errors. Also make sure the server is running production mode, in case you have not made any changes any configuration files for rails env, production mode is by default.
Please help to implement ssl
rails version - 3.2.8
I edtited following files:
# Gemfile
gem 'rack-ssl'
# config/application.rb
require 'rack/ssl'
config.middleware.use Rack::SSL
I also tried to use
# config/application.rb
config.force_ssl = true
But it shows
SSL connection error
when I access mysite:3000/
But it shows normal page if going to https:mysite
Please help,
thanks,
D
According to this:
How to use deactivate Webrick's SSL
The issue is caused by config.force_ssl = true. Even if you remove that, which you may not want, you might still have issues with WEBrick giving you this error. You could try clearing cookies, but that still might not work.
A better alternative, if it's an option for you, would be to switch to using the thin server:
group :development do
gem "thin"
end
Then:
$ bundle
$ thin start --ssl
See also https://stackoverflow.com/a/11614213
I'm working with Ruby On Rails (v. 3.0.10) and using Compass (0.11.5).
I'm using two development environments:
The standard Rails' development environment, defined in config/environments/development.rb connected to a PostgreSQL database.
A copy of the development environment, dev-sqlite, defined in config/environments/dev-sqlite.rb, with the only difference being the attached database (this time a local SQLite when I'm on the run and I can't reach my development database server).
My issue with Compass is that when I'm running Rails in my dev-sqlite environment (using RAILS_ENV='dev-sqlite' before running any Rails command, Compass seems to work in production mode, and it does not regenerate my CSS files when I change the SCSS ones as it does when I'm in development environment. This makes my development work a lot harder...
I've tried to add this line to the config/compass.rb file and restart my local Rails server (with rails s), without success:
environment = :development if Rails.env == 'dev-sqlite'
In fact, even environment = :development doesn't change a thing.
Thanks in advance for the help!
I added the following to the bottom of my config file and it works well for me:
# Enable Debugging (Line Comments, FireSass)
# Invoke from command line: compass watch -e development --force
if environment == :development
output_style = :expanded
sass_options = {:debug_info => true}
end
Then you just need to specify that you are in development environment when you run compass watch (or compile). You can do this by running compass watch -e development --force. As you can see, I stuck that in a comment in my config file incase I forget.
Also, be sure to enable sass in chrome developer tools to take advantage of sass source maps
I have an app that I run in three different environments, so sometimes when I pull it from github, I'll get the default rails "Oops, there was a problem with the server" page instead of the stack trace page. This seems to only happen when there's a problem related to a gem.
I remember maybe 6 months or a year ago when developing, if I had a missing gem, it'd show me the no such file to load -- mysql stack trace page.
This is mostly out of curiosity, but this actually does slow me down a bit as I have to tail the log to find what's broke on me.
You should add your gems in your environment.rb file.
For example if your application requires redcloth, you add in the environment file (the global one or any environment specific one).
config.gem 'RedCloth',
:lib => 'redcloth',
:version => '>= 4.2.2'
Your application won't load until you install that gem. And it'll display you a message asking you to install it.
You'll find more informations here.
Which server are you using to run your app?
Passenger runs in production mode unless explicitly told otherwise in the passenger configuration.
Any chance either of these lines appear uncommented in config/environemnt.rb?
ENV['RAILS_ENV'] ||= 'production'
ENV['RAILS_ENV'] = 'production'