Java Interview Preparation
Logging and Exception Handling Interview Questions
Logging frameworks, levels, correlation IDs, structured logs, and production troubleshooting.
Logging and Exception Handling Interview Focus
Logging frameworks, levels, correlation IDs, structured logs, and production troubleshooting.
Interview questions
1. Which logging framework does Spring Boot use by default? Beginner
Spring Boot uses SLF4J as the logging facade with Logback as the default implementation. SLF4J lets application code use a stable API while the underlying logging implementation can change.
2. What is SLF4J? Beginner
Spring Boot uses SLF4J as the logging facade with Logback as the default implementation. SLF4J lets application code use a stable API while the underlying logging implementation can change.
3. How do you configure logging levels? Beginner
Set levels with properties such as logging.level.org.springframework.web=INFO and use profile-specific configuration for different environments. Keep production logs useful without enabling verbose DEBUG globally.
4. How do you configure separate logging for different environments? Intermediate
Set levels with properties such as logging.level.org.springframework.web=INFO and use profile-specific configuration for different environments. Keep production logs useful without enabling verbose DEBUG globally.
5. How do you add a correlation ID to every request? Intermediate
Create or accept a request ID at the edge, put it in the logging context, return it in the response when appropriate, and forward it in outbound headers. Clear context when a thread is reused.
6. How do you propagate correlation IDs to downstream services? Advanced
Create or accept a request ID at the edge, put it in the logging context, return it in the response when appropriate, and forward it in outbound headers. Clear context when a thread is reused.
7. How do you log HTTP requests and responses? Intermediate
Use a filter or observability library and log method, path, status, duration, and a safe request ID. Never log passwords, tokens, cookies, or unrestricted personal data; mask or omit sensitive fields.
8. How do you mask sensitive information in logs? Advanced
Use a filter or observability library and log method, path, status, duration, and a safe request ID. Never log passwords, tokens, cookies, or unrestricted personal data; mask or omit sensitive fields.
9. What is structured logging? Intermediate
Structured logging writes fields such as timestamp, level, service, trace ID, route, and error type in a machine-readable format such as JSON. It makes searching and aggregation more reliable than parsing prose messages.
10. How do you configure JSON logging? Intermediate
Structured logging writes fields such as timestamp, level, service, trace ID, route, and error type in a machine-readable format such as JSON. It makes searching and aggregation more reliable than parsing prose messages.
11. How do you troubleshoot production exceptions using logs? Advanced
Logging and observability help developers understand application behaviour and investigate failures safely. Start with the definition, understand which problem it solves, and then apply it in a small example. In an interview, explain the normal use, the main trade-off, and one practical mistake to avoid.
How to Prepare for Java Technical Interviews
Use this Java technical interview question bank to revise core concepts and practise explaining your decisions clearly. The questions cover Java fundamentals, object-oriented programming, collections, exceptions, multithreading, Spring Boot, Hibernate, databases, and other topics used in real software development interviews.
Start with the fundamentals, then move to scenario-based questions and advanced topics. Filter questions by difficulty to build confidence gradually. A strong answer should define the concept, explain why it matters, and include a practical example when appropriate.
Continue your preparation with the Java tutorials, or explore all interview preparation tracks for managerial and company-focused questions.
