Thin server: ouput rails application logs to console, as 'rails s' does

后端 未结 2 413
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-02 10:39

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 wha

相关标签:
2条回答
  • 2021-01-02 10:59

    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))
    
    0 讨论(0)
  • 2021-01-02 11:05

    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)
    
    0 讨论(0)
提交回复
热议问题