No description, website, or topics provided.
Ruby Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Gem Version

Make Rails log beautiful!

Colored log

2016-09-28 1 24 05

  • Thanks to fazibear/colorize, logged messages stand out according to their levels.
  • Messages align beautifully so you can start reading custom message instantly.



Your backtrace will be neat and understandable with Beautiful::Log::Formatter.

  • Only the file paths of your codes (app/..) are displayed and highlighted.
  • The paths are no longer verbosely long, they are shrunk to relative path from your project root.

Status Code

2016-12-10 1 30 33

2016-12-10 1 41 25

You don't miss the responses' safety any more. A log of response completion tells either your app responded correctly or not by intuitive colors. You can customize color according to status code range (hundread level e.g: 1..3.

Pretty-printd object

Thanks to awesome-print/awesome_print, a complex object is beautifully displayed. You won't be annoyed with messy long string of object description.

  • Hash


  • ActiveRecord instance


awesome-print/awesome_print supports more types to beautiflize.

All you need to do is rescue error, just log it Rails.logger.error e .

Logs in Rake tasks

Rake tasks are fully logged with Beautiful::Log::TaskLogging just by adding some codes to Rakefile .


Add this line to your application's Gemfile:

gem 'beautiful-log'
# or
gem 'beautiful-log', git: ''

And then execute:

$ bundle install

Or install it yourself as:

$ gem install beautiful-log


  • config/application.rb

    config.logger =["log"].first)
    config.logger.formatter =
  • config/environments/development.rb

    config.log_level = :debug # set the level you need

You can change the log level from :debug to :fatal depending on staging level (develop/production/test).

  • Rakefile

    Rails.logger =
    Rails.logger.formatter =
    Rails.logger.level = Logger::DEBUG # set the level you need
  • Or just include in application.rb

    module YourApplication
      class Application < Rails::Application
        # This is equivalent to code below:
        #   Rails.logger =['log'].first)
        #   Rails.logger.formatter =
        include Beautiful::Log


You can customize the log appearance by passing a hash to constructor of Beautiful::Log::Formatter.

Below is a hash containing default values.
  only_project_code: true,
  backtrace_ignore_paths: [],
  highlighted_line_range: 3,
  highlighted_line_styles: :cyan,
  backtrace_styles: :light_red,
  error_file_path_styles: :red,
  severity_styles: { FATAL: [:red, :swap], ERROR: :red, WARN: :light_red },
  status_code_styles: { (1..3) => [:green, :bold], 'other' => [:red, :bold] },


  • backtrace_ignore_paths includes bundle path if you use Bundler. The bundle path is a string Bundler.bundle_path returns, which is written in .bundle/config .

  • If you pass a hash as status_code_styles or severity_styles, those styles are merged with default values shown above.

Style specification

  • For *_styles keys, you can set a Symbol or an Array of Symbol to style a string (color, bold, underline, etc). The elements of the array are applied in order.

  • Pick your favorite color or style (called 'mode' in fazibear/colorize) below.


  • Ruby 2.3-


  • If you find any problematic behaviors, please make an issue with problem backtrace.
  • If you want to make changes, fork this repository, then make a pull request.


  • Specs
  • Is is smarter to pass a proc/block to customize log style?