0
0
Spring Bootframework~20 mins

Log formatting configuration in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Log Formatting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
Understanding log pattern output in Spring Boot
Given this log pattern configuration in Spring Boot:
logging.pattern.console=%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n

What will be the output format of a log entry?
ATime in hours, minutes, seconds, milliseconds, thread name in brackets, log level left-padded to 5 chars, logger name truncated to 36 chars, message, newline
BDate in yyyy-MM-dd format, thread name in brackets, log level right-padded to 5 chars, full logger name, message, newline
CTimestamp in milliseconds, thread name without brackets, log level uppercase, logger name full, message, newline
DTime in HH:mm:ss format, thread id in brackets, log level left-padded to 5 chars, logger name truncated to 20 chars, message, newline
Attempts:
2 left
💡 Hint
Look carefully at the pattern symbols: %d{HH:mm:ss.SSS}, [%thread], %-5level, %logger{36}, %msg%n
📝 Syntax
intermediate
2:00remaining
Identify the invalid log pattern syntax
Which of the following Spring Boot log pattern configurations will cause a syntax error or fail to format logs correctly?
Alogging.pattern.console=%d{HH:mm:ss.SSS [%thread] %-5level %logger{36} - %msg%n
Blogging.pattern.console=%d{HH:mm:ss} [%thread] %-5level %logger{20} - %msg%n
Clogging.pattern.console=%d{HH:mm:ss.SSS} [%thread] %level %logger{36} - %msg%n
Dlogging.pattern.console=%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
Attempts:
2 left
💡 Hint
Check for missing or misplaced braces and brackets in the pattern.
state_output
advanced
2:00remaining
Effect of changing log pattern on output
If you change the Spring Boot log pattern from:
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n

to:
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{10} - %msg%n

What is the main visible difference in the log output?
AThe message will be omitted from the output, showing only metadata.
BThe timestamp will show only time with milliseconds, and the logger name will be fully displayed.
CThe timestamp will include the full date and time, and the logger name will be truncated to 10 characters instead of 36.
DThe thread name will be removed from the output, and the log level will be right-padded.
Attempts:
2 left
💡 Hint
Compare the date format and logger name length in both patterns.
🔧 Debug
advanced
2:00remaining
Diagnose missing thread name in logs
You configured your Spring Boot log pattern as:
logging.pattern.console=%d{HH:mm:ss.SSS} %thread %-5level %logger{36} - %msg%n

But the logs do not show the thread name in brackets as expected. What is the cause?
AThe %thread placeholder is invalid and should be %t instead.
BThe logger name truncation %logger{36} removes the thread name from output.
CThe log level placeholder %-5level must come before the thread name to show it correctly.
DThe pattern is missing brackets around %thread, so thread name appears without brackets.
Attempts:
2 left
💡 Hint
Look at how the thread name is enclosed in the pattern.
🧠 Conceptual
expert
2:00remaining
Understanding log pattern placeholders and their effects
Which of the following statements about Spring Boot log pattern placeholders is TRUE?
A%level outputs the log level in uppercase by default.
B%msg outputs the log message without a newline character.
C%logger{length} truncates the logger name to the specified number of characters from the end.
D%thread outputs the thread ID number instead of the thread name.
Attempts:
2 left
💡 Hint
Recall what each placeholder outputs exactly.