I need to run thin start
or thin -ssl ... start
within the root of my rails app, and see the application logs output to the console, similar to what rails s
does
Asked
Active
Viewed 4,070 times
9

Benjamin Bouchet
- 12,971
- 2
- 41
- 73
2 Answers
26
In config.ru
file, located at the root of your application, add the following code, just before the line run Rails.application
:
console = ActiveSupport::Logger.new($stdout)
console.formatter = Rails.logger.formatter
console.level = Rails.logger.level
Rails.logger.extend(ActiveSupport::Logger.broadcast(console))

Benjamin Bouchet
- 12,971
- 2
- 41
- 73
-
1But this is going to affect all environments, and most likely pollute the production machine logs. I am using thin in development because it's faster than Webbrick, is it possible to target only this environment ? – Cyril Duchon-Doris Jun 10 '15 at 22:52
-
3Simply wrap the above code in a `if Rails.env.development?` block – Benjamin Bouchet Jun 11 '15 at 06:50
-
@Benj This is the most marvelous answer ever provided on SO. I never thought that was possible. Now I have the colorful debug output using `thin`, thank you vey much. – W.M. Mar 11 '17 at 14:05
2
Make sure your config/environments/development.rb
file is configured to print logs, in case it is not, you can add these lines there and do not forget to restart the rails server.
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)

Edgar Ortega
- 1,672
- 18
- 22