0
0
Spring Bootframework~10 mins

Why logging matters in Spring Boot - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to log an info message in a Spring Boot application.

Spring Boot
logger.[1]("Application started successfully.");
Drag options to blanks, or click blank then click option'
Ainfo
Bdebug
Cwarn
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Using debug instead of info for general messages
Using error for normal startup messages
2fill in blank
medium

Complete the code to create a logger instance in a Spring Boot class.

Spring Boot
private static final Logger logger = LoggerFactory.[1](MyApplication.class);
Drag options to blanks, or click blank then click option'
AbuildLogger
BcreateLogger
CnewLogger
DgetLogger
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like createLogger
Confusing with constructor calls
3fill in blank
hard

Fix the error in the logging statement to correctly log an error message with an exception.

Spring Boot
logger.[1]("Failed to process request", e);
Drag options to blanks, or click blank then click option'
Awarn
Bdebug
Cerror
Dinfo
Attempts:
3 left
💡 Hint
Common Mistakes
Using warn or info instead of error for exceptions
Using debug which is too low level
4fill in blank
hard

Fill both blanks to log a warning message only if the variable 'user' is null.

Spring Boot
if ([1] == null) {
    logger.[2]("User object is null");
}
Drag options to blanks, or click blank then click option'
Auser
Binfo
Cwarn
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Checking wrong variable
Using info instead of warn for warnings
5fill in blank
hard

Fill all three blanks to create a log message with the user's name and age using placeholders.

Spring Boot
logger.[1]("User {} is {} years old", [2], [3]);
Drag options to blanks, or click blank then click option'
Ainfo
BuserName
CuserAge
Ddebug
Attempts:
3 left
💡 Hint
Common Mistakes
Using debug instead of info
Swapping the order of variables
Not using placeholders properly