How does a developer fix a violation?
Governance detects and records the problem automatically. But the fix always belongs to the developer. This chapter shows the exact code change that closes all three violations from our checkout log — and explains why each change matters.
Step 1 of 3
Understand what needs to change before writing any code
creditCardNumberCriticalVIO-0041The problem
This field is in disallowedFields. It must be removed from the log statement entirely. Do not mask it in code — governance already redacts it at runtime, but the violation will keep occurring until the field is removed from the source.
The fix
Remove creditCardNumber from the log statement. If you need to record payment context, log amount instead — it is not in disallowedFields.
correlationIdMediumVIO-0042The problem
This field is in requiredFields but was absent. Without it, this log line cannot be linked to a request trace in your APM or observability platform.
The fix
Add correlationId: Activity.Current?.Id ?? request.Headers["x-correlation-id"] to the log statement.
eventNameMediumVIO-0043The problem
This field is in requiredFields but was absent. Without it, log analysis tools cannot identify what kind of event this is, which breaks alerting rules and dashboards.
The fix
Add eventName: "CheckoutStarted" to the log statement as a string literal.
Step 2 of 3
Before and after — the complete code change
logger.LogInformation(
"Checkout started for {userId} paying with {creditCardNumber}",
request.UserId,
request.CreditCardNumber); // ← Critical: disallowed field
// Missing: correlationId // ← Medium: required, absent
// Missing: eventName // ← Medium: required, absentlogger.LogInformation(
"Checkout started {eventName} for {userId} {correlationId} amount {amount}",
"CheckoutStarted", // ← eventName: now present
request.UserId, // ← userId: was already correct
Activity.Current?.Id, // ← correlationId: now present
request.Amount); // ← amount: safe, not disallowed
// creditCardNumber removed entirely — no longer loggedStep 3 of 3
What happens after the fix is deployed
Governance Score
At Risk
3 open violations — 1 Critical, 2 Medium
creditCardNumberVIO-0041correlationIdVIO-0042eventNameVIO-0043Chapter 7 of 8
Try It Yourself — paste any log and see what governance does