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: docs/adrs/006-logging-strategy.md
+24-25Lines changed: 24 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,42 +2,41 @@
2
2
3
3
## Status
4
4
5
-
Proposed
5
+
Accepted
6
6
7
7
## Context
8
8
9
9
The AI SDK identified some challenges with debugging and problem resolution that can be addressed with better logging.
10
-
Typically, users had to enable wire logs to access information necessary for troubleshooting which, along with helpful logs, surfaces a large volume of unrelated ones.
11
-
Additionally, we identified the need to improve visibility into what's happening behind the scenes about application progress to the user.
10
+
Typically, users have to enable wire logs for troubleshooting which, along with helpful logs, surfaces a large volume of unrelated ones.
11
+
Additionally, we identified the need to improve visibility into application progress to the user.
12
12
13
-
Key challenges that drove this decision:
13
+
Key drivers for this decision include:
14
14
15
-
-**Debugging difficulties**: Limited visibility into request flows and processing steps
16
-
-**Security concerns**: Risk of accidentally logging sensitive information
17
-
-**User experience**: Users needed better insight into long-running AI operations
18
-
-**Trace ownership**: Reliance on external parties for troubleshooting details
15
+
-**Debugging difficulties**: Limited visibility into request flows.
16
+
-**Security risks**: Accidental logging of sensitive data.
17
+
-**Poor user experience**: Lack of insight into application progress.
18
+
-**Troubleshooting dependency**: Reliance on external parties for critical details.
19
19
20
20
## Decision
21
21
22
-
Devise and follow comprehensive logging guidelines that prioritize **debugging capability** and **user visibility** while maintaining **security** and **performance**.
23
-
The approach emphasizes descriptive, human-readable logs with structured request tracking through MDC (Mapped Diagnostic Context).
22
+
We will implement and enforce comprehensive logging guidelines that prioritize **debugging capability** and **user visibility**.
23
+
This approach mandates descriptive, human-readable logs with structured request tracking through Mapped Diagnostic Context (MDC).
24
24
25
25
## Guidelines
26
26
27
-
### 1. Content and Security
27
+
### 1. Log Content and Security
28
28
29
-
***Avoid sensitive information.**
30
-
As a general rule, avoid logging full request or response bodies.
31
-
Do not log any personally identifiable or confidential datasuch as names, IDs, tokens, or payload content.
29
+
-**Do not log sensitive information.**
30
+
Never log full request or response bodies.
31
+
Ensure that personally identifiable or confidential data—such as names, IDs, tokens, or payload content—is always excluded from logs.
32
32
33
-
***Keep logs concise and relevant.**
34
-
Every log should convey meaningful information without redundancy.
35
-
Avoid verbose, repetitive, or cosmetic details.
33
+
-**Write concise and relevant logs.**
34
+
Every log must convey meaningful information.
35
+
Avoid verbose, repetitive, or purely cosmetic details.
36
36
37
-
***Use descriptive, human-readable formats.**
38
-
Logs should read naturally and provide enough context for a developer to understand what happened without consulting the code.
39
-
While descriptiveness is a priority, follow the `metric=value` pattern where practical to include additional details with extensibility in mind.
40
-
Check out the example below.
37
+
-**Use descriptive, human-readable formats.**
38
+
Logs must be clear enough for a developer to understand what happened without checking the code.
39
+
Use the `metric=value` pattern to include structured details with extensibility in mind.
41
40
42
41
```[reqId=e3eaa45c] OpenAI request completed successfully with duration=1628ms, size=1,2KB.```
43
42
@@ -56,10 +55,10 @@ The approach emphasizes descriptive, human-readable logs with structured request
56
55
Keep per-request logs **below INFO level** (e.g., DEBUG or TRACE) to prevent cluttering normal application output.
57
56
58
57
***Application runtime logs.**
59
-
Prefer **INFO level** for one-time or startup/shutdown logs that occur once per application run.
58
+
Prefer **INFO level**only for one-time or startup/shutdown logs that occur once per application run.
60
59
61
60
***Avoid unnecessary warnings.**
62
-
Use the WARNING level only for actionable or genuinely concerning conditions.
61
+
Use the WARN level only for actionable or genuinely concerning conditions.
63
62
Do not use it as a placeholder or for expected transient states.
64
63
65
64
***Explicit request logging.**
@@ -69,7 +68,7 @@ The approach emphasizes descriptive, human-readable logs with structured request
69
68
This approach also avoids the need for stack-trace investigation when surface error responses are ambiguous.
70
69
71
70
***Performance-aware logging.**
72
-
If a log statement requires computation or inference to generate information, guard it with a log-level check (e.g., `if (log.isDebugEnabled())`) or other available context to avoid unnecessary overhead.
71
+
If a log statement requires expensive computation, guard it with a log-level check (e.g., `if (log.isDebugEnabled())`) to prevent performance degradation.
73
72
74
73
---
75
74
@@ -89,7 +88,7 @@ The approach emphasizes descriptive, human-readable logs with structured request
89
88
90
89
***Centralized MDC management.**
91
90
Avoid using magic strings for MDC keys or values.
92
-
Define them in a dedicated structure or utility (e.g., `RequestlogContext` class) to ensure discoverability and prevent errors during refactoring.
91
+
Define them in a dedicated structure or utility (e.g., `RequestLogContext` class) to ensure discoverability and prevent errors during refactoring.
93
92
94
93
***Responsibility and ownership.**
95
94
The component or class that sets MDC context values is also responsible for clearing them.
0 commit comments