0
0
Spring Bootframework~10 mins

Log formatting configuration in Spring Boot - Interactive Code Practice

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

Complete the code to set the log pattern to include timestamp and log level.

Spring Boot
logging.pattern.console=[1]
Drag options to blanks, or click blank then click option'
A%logger{36} - %msg%n
B%msg%n
C%d{yyyy-MM-dd HH:mm:ss} %-5level - %msg%n
D%thread %msg%n
Attempts:
3 left
💡 Hint
Common Mistakes
Using only %msg%n without timestamp or level
Forgetting to include the newline %n at the end
2fill in blank
medium

Complete the code to configure the log pattern to show thread name and logger name.

Spring Boot
logging.pattern.console=[1]
Drag options to blanks, or click blank then click option'
A%level %msg%n
B%thread %logger - %msg%n
C%msg%n
D%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the thread name
Not limiting logger name length with {36}
3fill in blank
hard

Fix the error in the log pattern to correctly display the log level padded to 5 characters.

Spring Boot
logging.pattern.console=%d{HH:mm:ss} [1] - %msg%n
Drag options to blanks, or click blank then click option'
A%-5level
B%level
C%5level
D%lev
Attempts:
3 left
💡 Hint
Common Mistakes
Using %level without padding
Using %lev which is invalid
4fill in blank
hard

Fill the blanks to create a log pattern that shows date, thread, log level, and message.

Spring Boot
logging.pattern.console=[1] [2] [3] - %msg%n
Drag options to blanks, or click blank then click option'
A%d{yyyy-MM-dd HH:mm:ss}
B%thread
C%-5level
D%logger
Attempts:
3 left
💡 Hint
Common Mistakes
Putting log level before date
Omitting thread name
5fill in blank
hard

Fill all three blanks to create a log pattern with logger name, log level, and message.

Spring Boot
logging.pattern.console=%d{HH:mm:ss} [[1]] [2] - [3]%n
Drag options to blanks, or click blank then click option'
A%logger{36}.toUpperCase()
B%-5level
C%msg
D%logger{36}
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to use Java methods like toUpperCase() in pattern
Omitting the message placeholder