0
0
Selenium Javatesting~10 mins

Logging with Log4j in Selenium Java - Interactive Code Practice

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

Complete the code to create a Logger instance for the class.

Selenium Java
private static final Logger logger = Logger[1](LoggingExample.class);
Drag options to blanks, or click blank then click option'
AgetLogger
BcreateLogger
CnewLogger
DinitLogger
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent method like createLogger.
Trying to instantiate Logger with new keyword.
2fill in blank
medium

Complete the code to log an info message using Log4j.

Selenium Java
logger.[1]("Test 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 or warn which are for problems.
3fill in blank
hard

Fix the error in the code to log an error message with an exception.

Selenium Java
try {
    int result = 10 / 0;
} catch (ArithmeticException e) {
    logger.[1]("Division by zero error", e);
}
Drag options to blanks, or click blank then click option'
Awarn
Bdebug
Cinfo
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Using warn instead of error for exceptions.
Logging exceptions with info or debug levels.
4fill in blank
hard

Fill both blanks to configure Log4j to log messages at debug level and above.

Selenium Java
BasicConfigurator.[1]();
Logger.getRootLogger().setLevel(Level.[2]);
Drag options to blanks, or click blank then click option'
Aconfigure
Binitialize
Cstart
Dsetup
Attempts:
3 left
💡 Hint
Common Mistakes
Using initialize instead of configure for setup.
Using lowercase level names.
5fill in blank
hard

Fill all three blanks to create a logger, log a warning, and set the logger level to WARN.

Selenium Java
Logger [1] = Logger.[2](MyTest.class);
[1].warn("This is a warning message.");
[1].setLevel(Level.[3]);
Drag options to blanks, or click blank then click option'
Alogger
BgetLogger
CWARN
DcreateLogger
Attempts:
3 left
💡 Hint
Common Mistakes
Using createLogger which does not exist.
Setting level to lowercase 'warn' instead of uppercase 'WARN'.