0
0
Spring Bootframework~10 mins

Logger creation in classes 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 create a logger instance in a Spring Boot class.

Spring Boot
private static final Logger logger = LoggerFactory.[1](MyClass.class);
Drag options to blanks, or click blank then click option'
AgetLogger
BcreateLogger
CnewLogger
DbuildLogger
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like createLogger or newLogger which do not exist.
Trying to instantiate Logger directly.
2fill in blank
medium

Complete the code to import the Logger class from the correct package.

Spring Boot
import org.slf4j.[1];
Drag options to blanks, or click blank then click option'
ALoggerFactory
BLogger
CLogManager
DLog
Attempts:
3 left
💡 Hint
Common Mistakes
Importing LoggerFactory instead of Logger.
Using LogManager which is from Log4j, not SLF4J.
3fill in blank
hard

Fix the error in the logger declaration by completing the code.

Spring Boot
private static final Logger logger = LoggerFactory.getLogger([1]);
Drag options to blanks, or click blank then click option'
Athis
B"MyClass"
CMyClass
DMyClass.class
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a class literal.
Passing an instance or 'this' keyword.
4fill in blank
hard

Fill both blanks to correctly declare and import the logger in a Spring Boot class.

Spring Boot
import org.slf4j.[1];

private static final Logger [2] = LoggerFactory.getLogger(MyService.class);
Drag options to blanks, or click blank then click option'
ALogger
Blogger
CLoggerFactory
Dlog
Attempts:
3 left
💡 Hint
Common Mistakes
Importing LoggerFactory instead of Logger.
Naming the logger variable incorrectly.
5fill in blank
hard

Fill all three blanks to complete the logger declaration with import and usage in a method.

Spring Boot
import org.slf4j.[1];

private static final Logger [2] = LoggerFactory.getLogger(AppController.class);

public void start() {
    [3].info("Application started");
}
Drag options to blanks, or click blank then click option'
ALogger
Blogger
DLoggerFactory
Attempts:
3 left
💡 Hint
Common Mistakes
Using LoggerFactory as a variable name.
Not importing Logger interface.
Calling info on LoggerFactory instead of logger.