0

When an exception is raised while running $ rails c, the logger writes over 100 lines of stack trace.

Does anyone know how to configure the logger to log N lines?

Rails 7, Ruby 3.1

I have tried the answer in set rails console stack backtrace limit permanently to no effect and obvious errors.

Michael Pell
  • 1,416
  • 1
  • 14
  • 17
  • There is no configuration for this in Rails or the Logger class as the Logger is ignorant of whether or not what is being logged is an Exception backtrace. In theory it appears you could create your own formatter (See [`ActiveSupport::Logger::SimpleFormatter`](https://github.com/rails/rails/blob/main/activesupport/lib/active_support/logger.rb#L86)) you could then check if the `severity == Logger::ERROR` and if so trim the `msg` (possibly via `msg.split("\n").take(10).join("\n")`) – engineersmnky Sep 29 '22 at 17:12

0 Answers0