QuizzesLogging in Java — Concept Check
intermediate
java

Logging in Java — Concept Check

Questions on Logging in Java. Effective logging uses SLF4J as the facade with Logback or Log4j2 as the implementation — structured, levelled, and never blocking.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Logging in Java — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer notices that their application logs are missing trace IDs for some HTTP requests. What might be the cause?

    • AMDC.clear() not called after request
    • BIncorrect log level set in logback.xml
    • CLogger not declared as private static final
    • DUsing string concatenation in logs
  2. 2.In a Java application, logs are showing sensitive user data. What is the best practice to prevent this?

    • AUse MDC to mask sensitive information
    • BAvoid logging sensitive data like passwords
    • CSet log level to WARN to hide sensitive data
    • DUse structured logging with JSON
  3. 3.A service using SLF4J and Logback is experiencing slow performance. Logs show high latency in log writes. What could improve this?

    • ASwitch to using string concatenation in logs
    • BRemove MDC usage to speed up logging
    • CUse async appenders for non-blocking logging
    • DIncrease log level to ERROR to reduce logging
  4. 4.A developer uses string concatenation in SLF4J log statements. What is a potential issue with this approach?

    • AIt incurs unnecessary performance costs
    • BIt automatically logs sensitive data
    • CString concatenation is skipped if log level is disabled
    • DIt can lead to incorrect log levels being set
  5. 5.In a multithreaded Java application, how can logs for a specific HTTP request be correlated?

    • ABy using a unique logger for each request
    • BBy logging at the ERROR level
    • CBy using Mapped Diagnostic Context (MDC)
    • DBy setting the log level to TRACE
  6. 6.A developer configures Logback with a root log level of INFO. What logs will be captured?

    • AOnly ERROR logs
    • BAll logs
    • CDEBUG and higher logs
    • DINFO and higher logs
  7. 7.Why should loggers in Java be declared as private static final?

    • ATo enable MDC usage
    • BTo avoid creating multiple logger instances
    • CTo ensure thread safety
    • DTo prevent log level changes at runtime