1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-07 09:08:01 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
jbranchaud
e3fc10edd8 Fix alphabetical ordering of Rails TILs 2025-02-26 16:53:08 -06:00
jbranchaud
4fe0817b2d Add Buy Me A Coffee Link to README 2025-02-26 16:52:32 -06:00
jbranchaud
fc74264040 Add Adjust The Production Log Level as a Rails TIL 2025-02-26 16:52:13 -06:00
2 changed files with 40 additions and 3 deletions

View File

@@ -10,12 +10,15 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1601 TILs and counting..._
_1602 TILs and counting..._
See some of the other learning resources I work on:
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
- [Vim Un-Alphabet](https://www.youtube.com/playlist?list=PL46-cKSxMYYCMpzXo6p0Cof8hJInYgohU)
If you've learned something here, support my efforts writing daily TILs by
[buying me a coffee](https://buymeacoffee.com/jbranchaud) 💜
---
### Categories
@@ -953,6 +956,8 @@ See some of the other learning resources I work on:
### Rails
- [Access Secrets In A Rails 5.2 App](rails/access-secrets-in-a-rails-5-2-app.md)
- [ActiveRecord Query For This Or That](rails/active-record-query-for-this-or-that.md)
- [Add A Check Constraint To A Table](rails/add-a-check-constraint-to-a-table.md)
- [Add A Database Index If It Does Not Already Exist](rails/add-a-database-index-if-it-does-not-already-exist.md)
- [Add A Foreign Key Reference To A Table](rails/add-a-foreign-key-reference-to-a-table.md)
@@ -961,8 +966,7 @@ See some of the other learning resources I work on:
- [Add ActiveRecord Error Not Tied To Any Attribute](rails/add-activerecord-error-not-tied-to-any-attribute.md)
- [Add React With Webpacker To A New Rails App](rails/add-react-with-webpacker-to-a-new-rails-app.md)
- [Add timestamptz Columns With The Migration DSL](rails/add-timestamptz-columns-with-the-migration-dsl.md)
- [Access Secrets In A Rails 5.2 App](rails/access-secrets-in-a-rails-5-2-app.md)
- [ActiveRecord Query For This Or That](rails/active-record-query-for-this-or-that.md)
- [Adjust The Production Log Level](rails/adjust-the-production-log-level.md)
- [Advance The Date](rails/advance-the-date.md)
- [Allow Associations To Be Optional](rails/allow-associations-to-be-optional.md)
- [Allow List Params Anywhere With Strong Params](rails/allow-list-params-anywhere-with-strong-params.md)

View File

@@ -0,0 +1,33 @@
# Adjust The Production Log Level
A Rails app by default takes on the `debug` log level. This is great for
development because it spits out a lot of information as you build and debug.
That's going to typically be a bit too noisy for a production environment
though. That is why Rails ships with the `config/environments/production.rb`
file configured to the `info` log level.
```ruby
# config/environments/production.rb
Rails.application.configure do
# ...
# "info" includes generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
# want to log everything, set the level to "debug".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
# ...
end
```
Sometimes, like when we're trying to track down some buggy behavior, we may
want to switch Rails from one log level to another. That's why it is configured
by the `RAILS_LOG_LEVEL` env var and otherwise falls back to `info`.
To, for example, switch production over to the `debug` log level, we'd first
change the `RAILS_LOG_LEVEL` env var to `debug`. Then we'd need to make sure
our Rails app is restarted so that the config change is picked up. Heroku's
`heroku config:set` will do that automatically. Depending on your setup, you
may need to manually restart your web server (e.g. Puma).