📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Logging

ILogger, logging providers, Serilog, NLog, structured logging, log scopes, correlation IDs and OpenTelemetry logging in ASP.NET Core.

  1. What is ILogger<T> in ASP.NET Core? Explain the log levels, what a log category is, and how you filter logs per category in appsettings.json.

    ILogger<T> basics: the six log levels plus None, categories derived from the type name, the Logging:LogLevel section in appsettings.json, per-provider overrides, most-specific-prefix matching and the default levels in the ASP.NET Core templates.

    Beginner Theory Logging Β· πŸ”— 3 follow-ups
  2. What logging providers come with .NET (console, debug, EventSource, EventLog) and which ones do you add for Application Insights and OpenTelemetry? How does ILoggerFactory send one log call to several providers, and how do you choose and configure them?

    Logging providers in Microsoft.Extensions.Logging: the defaults added by WebApplication.CreateBuilder (Console, Debug, EventSource, EventLog on Windows), adding OpenTelemetry or Azure Monitor, ClearProviders, how ILoggerFactory fans a call out to one ILogger per provider with per-provider filtering, console formatters and the cost of synchronous providers.

    Junior Theory Logging Β· πŸ”— 3 follow-ups
  3. What is structured logging? Explain message templates versus string interpolation (and the CA2254 warning), how named placeholders become properties, and why this matters when you query logs in Application Insights or Seq.

    Structured logging in .NET: message templates with named placeholders, how LogValues keeps the template and arguments separately, why $"..." interpolation destroys properties and allocates even when filtered (CA2254), the @ and $ destructuring hints in Serilog, KQL queries over customDimensions, cardinality and naming conventions.

    Intermediate Theory Logging Β· πŸ”— 3 follow-ups
  4. Show me how you write high-performance logging in .NET. Use the [LoggerMessage] source generator, explain what it does differently from logger.LogInformation(...) with arguments, when IsEnabled checks still matter, and how you would prove the difference with a benchmark.

    High-performance logging: the cost of LoggerExtensions calls (params object[] allocation, boxing, template parsing), the [LoggerMessage] source generator on partial methods, generated IsEnabled checks and cached delegates, CA1848, guarding expensive arguments with IsEnabled, and a BenchmarkDotNet comparison with MemoryDiagnoser.

    Mid-Level Coding Logging Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  5. Serilog, NLog, or the built-in Microsoft.Extensions.Logging with OpenTelemetry: how does each plug into ASP.NET Core, what are sinks, targets and enrichers, and how would you choose for a new .NET 10 service today?

    Comparing logging stacks for ASP.NET Core on .NET 10: Serilog (AddSerilog, two-stage bootstrap, sinks, enrichers, Serilog.Settings.Configuration), NLog (UseNLog, targets, layouts, nlog.config), and the built-in abstraction with OpenTelemetry exporters; how each sits behind ILogger, what OpenTelemetry changes, and a decision guide.

    Intermediate Theory Logging Β· πŸ”— 2 follow-ups
  6. How do you correlate all the logs for one request across services? Explain log scopes with BeginScope, how Activity and the W3C traceparent header give you a trace id, how that id propagates to HttpClient calls and message queues, and whether you still need a custom correlation ID.

    Log scopes and correlation in ASP.NET Core: ILogger.BeginScope and scope providers, the hosting scope (RequestId, RequestPath), ActivityTrackingOptions adding TraceId and SpanId, System.Diagnostics.Activity and AsyncLocal flow, W3C Trace Context (traceparent, tracestate, baggage), automatic propagation through HttpClient, propagating through Azure Service Bus messages, and when a business correlation ID is still useful.

    Mid-Level Theory Logging Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  7. How do you set up OpenTelemetry in an ASP.NET Core service? Explain how logs, traces and metrics fit together, what the OTLP exporter and the Azure Monitor distro each do, and how you approach sampling so you keep the useful data without an enormous bill.

    OpenTelemetry in ASP.NET Core on .NET 10: the three signals and how logs carry TraceId/SpanId, AddOpenTelemetry with WithTracing, WithMetrics and WithLogging, resource attributes, built-in ASP.NET Core and HttpClient instrumentation and meters, UseOtlpExporter vs the Azure Monitor distro (UseAzureMonitor, rate-limited sampling default since 1.5), head versus tail sampling in the Collector, and cost control.

    Senior Theory Logging Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  8. How do you keep personal information and secrets out of your logs in an ASP.NET Core service? Cover what must never be logged, data classification and redaction with Microsoft.Extensions.Compliance.Redaction, HTTP logging, and what the Privacy Act (APP 11) means for log retention and breaches.

    Secure logging: what counts as secrets and personal information, why logs are a breach surface, Microsoft.Extensions.Compliance.Redaction (data classification attributes, AddRedaction, EnableRedaction, erasing and HMAC redactors, [LogProperties]), safe HTTP logging and header allowlists, scanning and testing for leaks, and Australian Privacy Act APP 11, APP 11.2 retention and the Notifiable Data Breaches scheme.

    Senior Security Logging Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  9. Your Application Insights bill has tripled in a month and API latency has risen, and both trace back to logging. How do you find exactly what is producing the volume, fix log levels, sampling and sinks, and keep costs under control without losing the data you need for incidents?

    A real-world logging cost and latency incident: finding ingestion sources with KQL over _BilledSize by table, category and template, common causes (Debug left on, EF Core command logging, HTTP body logging, duplicate pipelines, health-check noise, disabled sampling), latency from synchronous or blocked log writes, fixes in levels, filters, sampling and sinks, and long-term controls such as daily caps, table plans, transformations and cost alerts.

    Senior RealWorldScenario Logging Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me