Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Unable to control production DB log  #607

@ablce9

Description

@ablce9

The db log is always logged and we'd like to make it go away at production environment. Looked through documentations and source code and finally reached this PR. I reckon no options available to disable SQL logging?
I worked on a few hours and found a workaround that is:

# config/initializers/models.rb
unless Hanami.env?(:development)
  Hanami::Model.configuration.connection.loggers = []
end

The solution worked.

Is this a legit solution to disable log? This issue should be tagged as question.

Tried following but nothing seems effective

# config/environment.rb
  model do
    adapter :sql, ENV.fetch('DATABASE_URL') 

    gateway do |g|
      g.use_logger(Hanami::Logger.new(nil, '/dev/null'))
      g.connection.loggers = []
    end

    logger '/dev/null'

    ##
    # Migrations
    #
    migrations 'db/migrations'
    schema     'db/schema.sql'
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions