Challenge - 5 Problems
Log4j2 Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Log4j Basic Configuration Output
Given this Log4j2 configuration snippet, what will be the output when the logger logs an info message?
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss} %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>Selenium Java
Logger logger = LogManager.getLogger("MyLogger"); logger.info("Test message");
Attempts:
2 left
💡 Hint
Check the root logger level and the message level.
✗ Incorrect
The root logger is set to level INFO, so info messages are logged. The pattern layout formats the output with time, level, logger name, and message.
❓ Troubleshoot
intermediate2:00remaining
Log4j2 Logger Not Printing Messages
You have this Java code snippet using Log4j2:
The log file remains empty after running the program. What is the most likely cause?
Logger logger = LogManager.getLogger(MyClass.class);
logger.debug("Debug message");The log file remains empty after running the program. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check the configured log level and the message level.
✗ Incorrect
If the configured log level is INFO or higher, DEBUG messages will not be logged, causing the log file to remain empty.
❓ Configuration
advanced2:30remaining
Log4j2 Rolling File Appender Configuration
Which Log4j2 XML configuration snippet correctly sets up a rolling file appender that rolls over daily and keeps 7 days of logs?
Attempts:
2 left
💡 Hint
Look for daily rollover and max 7 files retention.
✗ Incorrect
Option B uses TimeBasedTriggeringPolicy with interval 1 for daily rollover and DefaultRolloverStrategy max 7 to keep 7 days of logs.
🔀 Workflow
advanced2:00remaining
Integrating Log4j2 with Selenium Tests
You want to add Log4j2 logging to your Selenium Java tests to log browser actions. Which step is NOT required in the integration workflow?
Attempts:
2 left
💡 Hint
Consider what logging does versus what Selenium does.
✗ Incorrect
You do not replace Selenium WebDriver calls with Log4j2 calls; logging is added alongside Selenium calls to record actions.
✅ Best Practice
expert3:00remaining
Best Practice for Sensitive Data in Log4j2 Logs
Which is the best practice to avoid logging sensitive data (like passwords) in Log4j2 logs during automated tests?
Attempts:
2 left
💡 Hint
Think about controlling what gets logged rather than deleting logs later.
✗ Incorrect
Using a custom filter to mask or exclude sensitive data ensures sensitive info never appears in logs, which is safer and more reliable.