DEV Community


Posted on

A new gem that eliminates the hassle of launching the Rails app every time just to check the logs.


During Rails development, I found that the wait time to start the Rails server was surprisingly stressful. On the other hand, the logs output to development.log were often overwhelming...

So, I created a gem that divides and outputs the logs by each controller's action in separate folders, allowing for easier management of logs during each request.

custom_log_space | | Community Gem Hosting Service


Add gem 'custom_log_space' to your Gemfile as shown below and run bundle install.

group :development do
  + gem 'custom_log_space'
Enter fullscreen mode Exit fullscreen mode


Launch your Rails app locally. When you access a page, logs will be generated in the log/custom_log_space directory, following the naming convention below.

Enter fullscreen mode Exit fullscreen mode


user log % tree
├── custom_log_space
│   └── articles_controller
│       ├── index
│       │   ├── 2023-09-19
│       │   │   ├── 09:13.log
│       │   │   └── 20:00.log
│       │   └── saved
│       └── show
│           ├── 2023-09-18
│           │   ├── 21:29.log
│           │   └── 22:02.log
│           ├── 2023-09-19
│           │   └── 20:00.log
│           └── saved
└── development.log
Enter fullscreen mode Exit fullscreen mode

Log Retention Policy

  • The maximum number of #{date} folders retained is two, and for #{time}.log, up to 10 files. Once these limits are exceeded, older files will be deleted sequentially.
  • Please move important logs to the saved directory. log/custom_log_space/#{controller_name}/#{action_name}/saved/


  • If a single request triggers multiple controller actions, logs will be organized into separate folders for each action. Therefore, caution is needed when tracing the logs.
  • However, even after introducing this gem, the output to the existing development.log remains unchanged. You can continue to refer to it as needed.

Top comments (0)