Entity Framework Core Interview Question #194
How should sensitive data logging be handled?
Testing, Production Practices & Senior Real-World Scenarios Senior Advanced
Quick Interview Answer
Sensitive data logging can include parameter values and other data in EF Core diagnostics, which is useful during controlled debugging but risky in production. Do not enable it broadly where logs may contain passwords, tokens, personal data, or confidential business information. Prefer safe structured diagnostics and tightly controlled temporary troubleshooting when detailed values are genuinely required.
Detailed Explanation
Sensitive data logging can include parameter values and other data in EF Core diagnostics, which is useful during controlled debugging but risky in production. Do not enable it broadly where logs may contain passwords, tokens, personal data, or confidential business information. Prefer safe structured diagnostics and tightly controlled temporary troubleshooting when detailed values are genuinely required.
Code Example
// Development/debugging only when appropriate:
// options.EnableSensitiveDataLogging();
// Avoid broad production use.