Logging Flashcards
What is slf4j?
Simple logging framework for Java. Slf4j provides a series of interfaces to work with different logging implementations.
What are some logging frameworks that implement slf4j?
Log4j, log4j2, and logback. These frameworks implement the logic that slf4j abstracts.
What is the slf4j api?
The slf4j api redirects requests made to the underlying implementation of slf4j. This allows other logging frameworks that implement the slf4j api to be interchangeable underneath the hood. This allows developers to use one implementation during development and easily switch to another during production.
Which implementation of slf4j is built into Spring Boot?
Logback is built into Spring Boot.
What are the logging levels?
In order from lowest to highest priority: ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF.
What is the INFO logging level used for?
INFO level logs represent business events and processes and whether they were completed successfully. These logs are used by SRE to monitor the application status.
What is the WARN logging level used for?
The WARN logging level is used to flag events where the application is able to continue executions, but extra precautions are needed.
What is the ERROR logging level used for?
The ERROR logging level is used to indicate that something has gone wrong and should be investigated. This level should be used when the application is not servicing requests correctly (i.e. 5XX status code) or when an event causes an SLI to go down or begin eating into the error budget.
What is the FATAL logging level used for?
The FATAL logging level is used for events that cause the application to fail. These are usually rare.
What logging level would you use to see logs of all levels?
ALL
What logging level would you use to turn off all logs?
OFF
What does MDC stand for?
Mapped Diagnostic Context
What is the MDC used for?
The MDC is used to store key value pairs temporarily to provide extra context and information to our logs.
How do we add new information to the MDC?
MDC.put(key, value);
How do we remove all information from the MDC?
MDC.clear();