When log level is set to WARN, only messages with level WARN and ERROR (higher severity) are shown.
Step 2: Identify which messages appear
Info messages are below WARN level, so they are ignored. Warning and error messages are shown.
Final Answer:
Warning message, Error message -> Option D
Quick Check:
Log level WARN shows WARN and ERROR [OK]
Hint: Log level filters out lower severity messages [OK]
Common Mistakes:
Expecting info messages to appear at WARN level
Confusing log levels order
Assuming all messages always print
4. You see no logs appearing in your Spring Boot console even though you added logger.info("Starting app");. What is the most likely cause?
medium
A. The log level is set higher than INFO, so info messages are hidden.
B. The logger.info() method is misspelled.
C. Spring Boot does not support logging by default.
D. The application has no internet connection.
Solution
Step 1: Check log level configuration
If the log level is set to WARN or ERROR, info messages will not show in the console.
Step 2: Rule out other causes
Logger method spelling is correct, Spring Boot supports logging by default, and internet connection does not affect logging.
Final Answer:
The log level is set higher than INFO, so info messages are hidden. -> Option A
Quick Check:
Log level hides lower severity logs [OK]
Hint: Check log level if logs don't appear [OK]
Common Mistakes:
Assuming logging needs extra setup always
Blaming internet connection for logging issues
Ignoring log level settings
5. You want to log an error with a message and the exception stack trace in Spring Boot. Which code snippet correctly does this?
hard
A. logger.warn("Error occurred", exception);
B. logger.error("Error occurred", exception);
C. logger.info("Error occurred" + exception);
D. logger.error(exception);
Solution
Step 1: Understand logging exceptions
To log an error with stack trace, use logger.error(message, throwable) method.
Step 2: Identify correct usage
logger.error("Error occurred", exception); passes both a message and the exception object, so it logs the message and stack trace properly.
Step 3: Rule out other options
Other options are incorrect: logging only the exception misses the message, using warn level is less severe than error, using info level and string concatenation does not properly log the stack trace.
Final Answer:
logger.error("Error occurred", exception); -> Option B
Quick Check:
Use logger.error(message, exception) for errors [OK]
Hint: Use logger.error(msg, exception) to log errors with stack trace [OK]
Common Mistakes:
Logging exceptions as strings instead of passing throwable
Using wrong log level for errors
Omitting the error message
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.