The discussion revolves around the inability to view info-level logs in production mode in Discourse. griegm seeks to debug slow queries and wants to temporarily set the log level to debug, but finds it hardcoded to warn in production mode (code reference). merefield confirms the issue, noting that even Rails.logger.info logs don’t appear in the /logs interface, despite being present in production.log. RGJ explains that Logster suppresses info and debug logs in production by design, as it only aggregates warnings, errors, and fatal messages to focus on actionable issues (Logster railtie). While this is standard practice, merefield argues that it should be configurable for edge cases, such as debugging rare production issues.
I’m currently trying to debug some slow queries that are only happening in environments which run in production mode. I noticed that the log level appears to be hardcoded in production mode (code reference) with no way to directly configure it. I’d like to change this log level to debug (at least temporarily) so I can see more information; is there a way to accomplish this?
I tried some pretty hacky workarounds which involved changing the log level during runtime with the Rails console, but none of the hacks resulted in DB queries showing up in the debug logs (if I manually did debug logs with Rails.logger.debug in the Rails console those did show up after the hacks, though).
Thanks!
P.S. Just to soothe any potential worries about my comment above about issues that only happen in production environments, I’m using Discourse in a quite non-standard way that involves a large number of categories; the issues I’m facing probably aren’t faced by any other Discourse instances.
In production mode it aggregates similar errors by fingerprinting backtraces listening for warnings/errors and fatal messages. The intention is to display a list of open application problems that can somehow be resolved.
In development mode it provides a full fire-hose of all logs produced by Rails. (debug and up). This has significant advantages over console as you have proper access to backtraces for every log line.