Skip to content

Commit ee1b855

Browse files
authored
Set default production log level to info (#1010)
## Summary - default production log level to info - document that debug logs are for troubleshooting - warn in production when debug logs are enabled ## Testing - `bin/ci` *(fails: bundler: command not found: rails)* - `bundle exec rubocop` *(fails: bundler: command not found: rubocop)* - `bundle exec brakeman -q -w2` *(fails: bundler: command not found: brakeman)* - `bundle exec bundler-audit --update` *(fails: bundler: command not found: bundler-audit)* - `bin/codex_style_guard` *(fails: bundler: command not found: rubocop)* ------ https://chatgpt.com/codex/tasks/task_e_689b685334848321a71aedc20ae48931
2 parents 79840e3 + f566494 commit ee1b855

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.env.prod.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PORT=5000
2424

2525
RACK_ENV=production
2626
RAILS_ENV=production
27-
RAILS_LOG_LEVEL=debug
27+
RAILS_LOG_LEVEL=info
2828
RAILS_LOG_TO_STDOUT=true
2929
RAILS_SERVE_STATIC_FILES=true
3030

docs/production/deployment-dokku.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@ dokku docker-options:add communityengine.app build '--build-arg FOG_HOST'
5959
dokku docker-options:add communityengine.app build '--build-arg FOG_REGION'
6060
dokku docker-options:add communityengine.app build '--build-arg ASSET_HOST'
6161
dokku docker-options:add communityengine.app build '--build-arg CDN_DISTRIBUTION_ID'
62-
```
62+
```
63+
64+
## Logging
65+
66+
Configure the application log level with the `RAILS_LOG_LEVEL` environment variable. Use `info` or `warn` in production and reserve `debug` for troubleshooting.

spec/dummy/config/environments/production.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@
9696

9797
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym
9898

99+
if config.log_level == :debug
100+
config.after_initialize do
101+
Rails.logger.warn('RAILS_LOG_LEVEL is set to debug; use only for troubleshooting.')
102+
end
103+
end
104+
99105
# Do not dump schema after migrations.
100106
config.active_record.dump_schema_after_migration = false
101107

0 commit comments

Comments
 (0)