You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ We support all your other favorite gems too, like Sidekiq, Sentry, and Shrine. (
6
6
7
7
## Features
8
8
9
-
- JSON logging enabled by default in production and test environments
9
+
- JSON logging enabled by default for server processes in production and test environments (automatically disabled for console and Rake tasks)
10
10
- ActionMailer integration for email delivery logging
11
11
- ActiveJob integration for job execution logging
12
12
- Sidekiq integration for background job logging
@@ -58,11 +58,13 @@ Once initialized (and enabled), the gem automatically includes its modules into
58
58
- Rails `config.filter_parameters` are merged into LogStruct's filters and then cleared (to avoid double filtering). Configure sensitive keys via `LogStruct.config.filters`.
59
59
- When `RAILS_LOG_TO_STDOUT` is set, we log to STDOUT only. Otherwise, we log to STDOUT by default without adding a file appender to avoid duplicate logs.
60
60
61
-
### Development behavior
61
+
### Default behavior by process type
62
62
63
-
- Disabled by default in development. Enable explicitly via `LOGSTRUCT_ENABLED=true` or `LogStruct.configure { |c| c.enabled = true }`.
64
-
- When enabled in development, LogStruct now defaults to production‑style JSON output so you can preview exactly what will be shipped in prod.
65
-
- You can opt back into the colorful human formatter with:
63
+
-**Server processes** (`rails server`): JSON logging is enabled by default in production and test environments
64
+
-**Console and Rake tasks** (`rails console`, `rake`, etc.): JSON logging is disabled by default in all environments, providing human-readable logs instead
65
+
-**Development environment**: Disabled by default for all process types. Enable explicitly via `LOGSTRUCT_ENABLED=true` or `LogStruct.configure { |c| c.enabled = true }`.
66
+
67
+
When enabled in development, LogStruct defaults to production‑style JSON output so you can preview exactly what will be shipped in prod. You can opt back into the colorful human formatter with:
66
68
67
69
```ruby
68
70
LogStruct.configure do |c|
@@ -71,6 +73,8 @@ LogStruct.configure do |c|
71
73
end
72
74
```
73
75
76
+
To force JSON logs in console or Rake tasks (e.g., for debugging), set `LOGSTRUCT_ENABLED=true` in your environment.
77
+
74
78
## Documentation
75
79
76
80
Please see the [documentation](https://logstruct.com/docs) for more details. (All code examples are type-checked and tested, and it's harder to keep a README up to date.)
{`LogStruct is now installed and will automatically enable JSON structured logging in the test and production environments.`}
32
+
{`LogStruct is now installed and will automatically enable JSON structured logging for server processes in the test and production environments. Console and Rake tasks will use human-readable logs by default.`}
0 commit comments