The default Ruby Sequel behaviour is to log all DB queries at the INFO level (unlike ActiveRecord which logs at the DEBUG level). How do I change this?
How do I set Ruby Sequel logging to the DEBUG level?
Previously, it was fairly simple to do with a proxy logger object, but enough people have asked for this that I implemented it. With the git master branch of Sequel, you can now do:
DB.sql_log_level = :debug
Which will use the debug method instead of the info method when logging queries.
Probably in an initializer. It does depend on the Sequel::Database object being in DB, which may not be true if you are not loading it yourself. A safer bet is:Sequel::DATABASES.each{|d| d.sql_log_level = :debug} –
Kilo
Hi Jeremy, that answer was from 2010. I just tried it (
DB.sql_log_level = :debug
) and no debugging output at all. What is the currently working method? (Would be especially nice to see that here, since this is the first hit on Google...) –
Diagnose @Diagnose Make sure you supply a logger to the database:
require 'sequel'; require 'logger'; DB = Sequel.sqlite; DB.loggers << Logger.new($stdout); DB['select 1'].to_a
=> I, [2020-07-03T18:28:33.321470 #262544] INFO -- : (0.000376s) select 1
–
Shower © 2022 - 2024 — McMap. All rights reserved.