Logging Flashcards

1
Q

What is slf4j?

A

Simple logging framework for Java. Slf4j provides a series of interfaces to work with different logging implementations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some logging frameworks that implement slf4j?

A

Log4j, log4j2, and logback. These frameworks implement the logic that slf4j abstracts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the slf4j api?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which implementation of slf4j is built into Spring Boot?

A

Logback is built into Spring Boot.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the logging levels?

A

In order from lowest to highest priority: ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the INFO logging level used for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the WARN logging level used for?

A

The WARN logging level is used to flag events where the application is able to continue executions, but extra precautions are needed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the ERROR logging level used for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the FATAL logging level used for?

A

The FATAL logging level is used for events that cause the application to fail. These are usually rare.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What logging level would you use to see logs of all levels?

A

ALL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What logging level would you use to turn off all logs?

A

OFF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does MDC stand for?

A

Mapped Diagnostic Context

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the MDC used for?

A

The MDC is used to store key value pairs temporarily to provide extra context and information to our logs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do we add new information to the MDC?

A

MDC.put(key, value);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do we remove all information from the MDC?

A

MDC.clear();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do we use information stored in the MDC in our logback logs?

A

We use custom logging patterns defined in our logback.xml coniguration file. The correct syntax to specify a value is %X{key} inside the tags.

Another option: MDC.get(key);

17
Q

How do we remove a specific piece of information from the MDC?

A

MDC.remove(key);