When running multi-user, multi-account applications, it's often useful to be able to filter the logs using some custom rules.
logger = Active Support:: Tagged Logging.new(Logger.new(STDOUT)) logger.tagged("BCX") # Logs "[BCX] Stuff" logger.tagged("BCX", "Jason") # Logs "[BCX] [Jason] Stuff" logger.tagged("BCX") # Logs "[BCX] [Jason] Stuff" In the above example, there will be a performance impact even if the allowed output level doesn't include debug.
If you add extra logging, be sure to make sensible use of log levels to avoid filling your production logs with useless trivia.
If you want to know the current log level, you can call the Processing Articles Controller#create (for 127.0.0.1 at 2008-09-08 ) [POST] Session ID: BAh7Bzo MY3Ny Zl9p ZCIl MDY5MWU1M2I1ZDRj ODBl Mzky MWI1OTg2NWQy Nz Vi Zj Yi Cm Zs YXNo SUM6J0Fjd Gl vbk Nvbn Ryb2xs ZXI6Ok Zs YXNo Ojp Gb GFza Ehhc2h7AAY6Ck B1c2Vkew A=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4 Parameters: New article: Article should be valid: true Article Create (0.000443) INSERT INTO "articles" ("updated_at", "title", "body", "published", "created_at") VALUES('2008-09-08 ', 'Debugging Rails', 'I''m learning how to print in logs!!!
', 'f', '2008-09-08 ') The article was saved and now the user is going to be redirected...
ruby/object Article attributes: updated_at: 2008-09-05 body: It's a very helpful guide for debugging your Rails app.
title: Rails debugging guide published: t id: "1" created_at: 2008-09-05 attributes_cache: Title: Rails debugging guide When something is logged, it's printed into the corresponding log if the log level of the message is equal to or higher than the configured log level.