Challenge - 5 Problems
Log Formatting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
Understanding log pattern output in Spring Boot
Given this log pattern configuration in Spring Boot:
What will be the output format of a log entry?
logging.pattern.console=%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%nWhat will be the output format of a log entry?
Attempts:
2 left
💡 Hint
Look carefully at the pattern symbols: %d{HH:mm:ss.SSS}, [%thread], %-5level, %logger{36}, %msg%n
✗ Incorrect
The pattern specifies time with hours, minutes, seconds, milliseconds (%d{HH:mm:ss.SSS}), thread name in brackets ([%thread]), left-aligned log level with width 5 (%-5level), logger name truncated to 36 characters (%logger{36}), message (%msg), and newline (%n).
📝 Syntax
intermediate2: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?
Attempts:
2 left
💡 Hint
Check for missing or misplaced braces and brackets in the pattern.
✗ Incorrect
Option A is missing the closing brace '}' after the date pattern %d{HH:mm:ss.SSS}, causing a syntax error in the log pattern.
❓ state_output
advanced2:00remaining
Effect of changing log pattern on output
If you change the Spring Boot log pattern from:
to:
What is the main visible difference in the log output?
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%nto:
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{10} - %msg%nWhat is the main visible difference in the log output?
Attempts:
2 left
💡 Hint
Compare the date format and logger name length in both patterns.
✗ Incorrect
The new pattern changes the date format to include year, month, and day, and shortens the logger name to 10 characters, affecting the visible output accordingly.
🔧 Debug
advanced2:00remaining
Diagnose missing thread name in logs
You configured your Spring Boot log pattern as:
But the logs do not show the thread name in brackets as expected. What is the cause?
logging.pattern.console=%d{HH:mm:ss.SSS} %thread %-5level %logger{36} - %msg%nBut the logs do not show the thread name in brackets as expected. What is the cause?
Attempts:
2 left
💡 Hint
Look at how the thread name is enclosed in the pattern.
✗ Incorrect
The pattern lacks brackets [] around %thread, so the thread name is printed plainly without brackets.
🧠 Conceptual
expert2:00remaining
Understanding log pattern placeholders and their effects
Which of the following statements about Spring Boot log pattern placeholders is TRUE?
Attempts:
2 left
💡 Hint
Recall what each placeholder outputs exactly.
✗ Incorrect
Option B is true: %msg outputs the log message exactly as is, without adding a newline. The newline must be added explicitly with %n. Option B is false because %logger{length} truncates from the beginning, not the end. Option B is false because %level outputs the level in uppercase or lowercase depending on configuration but usually uppercase. Option B is false because %thread outputs the thread name, not the ID.