How to make `thin` webserver print log to STDOUT
Asked Answered
A

3

13

Context: To run localhost as SSL, I followed the instructions at this site

After setting up the SSL cert, to run the local rails server, the site says to:

thin start --ssl <some more options>

When I do that, I notice that I no longer see the Rails log being printed to STDOUT.

How can I pass the --ssl and other options to thin ? This does not work:

bundle exec rails s thin --ssl

.../rails/commands/server.rb:33:in `parse!': 
    invalid option: --ssl (OptionParser::InvalidOption)

Alternatively, how can I get thin to output the Rails log to STDOUT?

Arapaho answered 17/10, 2013 at 21:35 Comment(1)
Related: https://mcmap.net/q/157031/-no-route-matches-get-assetsAmoakuh
S
12

i think that you need to tell rails to use STDOUT for logging instead of logging to log/development.log by putting config.logger = Logger.new(STDOUT) in your app/config/environments/development.rb.

Selfpossessed answered 17/10, 2013 at 22:8 Comment(3)
Thanks, but that does not work for me because the logging then goes to STDOUT only, instead of to log file as well as STDOUT.Arapaho
i don't think there is another way. i did not even know that you have logs going to stdout when you are running rails with rails server. i always boot my applications using foreman and tail the logs within there.Selfpossessed
Thanks, foreman solves the problem nicely. I just add a entry for tailing the log file and it is nice!Arapaho
I
5

Well Thin explicitly does not log anything by default unless you specify it do so by passing options

-D or --debug and -V or --trace 

But having said that this would only track the request / response header of but not rails specific log since your are booting the rails as a rack app perhaps

I guess you need to start rails in ssl mode you can find couple of documentation over here and here

FYI to use thin as backend adapter in rails all you do is add gem 'thin' to the Gemfile and start rails it would start rails using thin adapter but you cant pass thin options like you do for when starting thin

Ideality answered 18/10, 2013 at 8:44 Comment(0)
L
0

Make sure your config/environments/development.rb file is configured to print logs, in case it is not, you can add these lines there.

logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
Lack answered 29/1, 2020 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.