ASP.NET Core Interview Question #247

How would you investigate intermittent 500 errors that cannot be reproduced locally?

Senior ASP.NET Core Real-World Scenarios Senior Advanced

Quick Interview Answer

Use centralized structured logs, exception details in protected telemetry, correlation or trace IDs, and distributed traces. Capture the request path, application version, instance, dependency timings, and safe contextual identifiers so failures can be grouped and compared.

Detailed Explanation

Use centralized structured logs, exception details in protected telemetry, correlation or trace IDs, and distributed traces. Capture the request path, application version, instance, dependency timings, and safe contextual identifiers so failures can be grouped and compared.

Look for patterns involving a particular input, server instance, database timeout, downstream dependency, concurrency condition, or deployment version. Metrics can show whether errors correlate with resource pressure or traffic spikes.

Do not return stack traces to public clients. Improve observability until the production failure leaves enough evidence to diagnose it.

Code Example

catch (Exception ex)
{
    _logger.LogError(
        ex,
        "Unhandled failure. TraceId {TraceId}",
        HttpContext.TraceIdentifier);

    throw;
}