Basic Logging Learn how to configure basic logging for your Hanami project

Basic Logging

This is the basic logging configuration for a Hanami project:

# config/environment.rb
# ...

Hanami.configure do
  # ...

  environment :development do
    logger level: :debug
  end

  environment :production do
    logger level: :info, formatter: :json

    # ...
  end
end

By default it uses standard output because it’s a best practice that most hosting SaaS companies suggest using.

If you want to use a file, pass stream: "path/to/file.log" as an option.

Each environment requires different logging behaviors, use environment blocks to define the differences.

Read more at https://guides.hanamirb.org/projects/logging/

Twitter Facebook

Want to learn more about Hanami?

We have written an extensive Getting Started guide for curious people like you.