- log4j - Home
- log4j - Overview
- log4j - Installation
- log4j - Architecture
- log4j - Configuration
- log4j - Sample Program
- log4j - Logging Methods
- log4j - Logging Levels
- log4j - ConsoleAppender
- log4j - Logging in Database
Log4j - Formatting Layouts
- log4j - Log Formatting
- log4j - CSV Parameter Layout
- log4j - CSV Log Event Layout
- log4j - HTML Layout
- log4j - Pattern Layout
- log4j - Json Template Layout
Log4j - File Appenders
- log4j - Logging in Files
- log4j - FileAppender
- log4j - Separate Folder per Month
- log4j - Daily log File Generation
log4j Resources
log4j Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to log4j Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - Which of the following is correct about log4j?
A - It is designed to handle Java Exceptions from the start.
B - It uses multiple levels, namely ALL, TRACE, DEBUG, INFO, WARN, ERROR and FATAL.
C - The format of the log output can be easily changed by extending the Layout class.
Answer : D
Explanation
All of the above options are correct.
Q 2 - Which of the following is correct about Filter object?
B - An Appender objects can have several Filter objects associated with them.
Answer : C
Explanation
Both of the above options are correct.
Q 3 - Which of the following method of logger print a log message in info mode?
A - public void debug(Object message)
B - public void error(Object message)
Answer : D
Explanation
public void info(Object message) of Logger class prints messages with the level Level.INFO.
Q 4 - Which of the following level designates finer-grained informational events than the DEBUG?
Answer : B
Explanation
TRACE − Designates finer-grained informational events than the DEBUG.
Q 5 - What is the purpose of n character used in the conversionPattern of PatternLayout object?
A - Outputs the platform dependent line separator character or characters.
B - Used to output the priority of the logging event.
D - Used to output the name of the thread that generated the logging event.
Answer : A
Explanation
n − Outputs the platform dependent line separator character or characters.
Q 6 - What is the purpose of x character used in the conversionPattern of PatternLayout object?
B - Used to print the information stored in the MDC against the key.
D - Used to Left pad with spaces if the category name is less than 20 characters long.
Answer : A
Explanation
x − Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.
Q 7 - What is the purpose of bufferSize configuration of FileAppender?
A - logging information to be appended to the end of the same file.
Answer : C
Explanation
bufferSize − If buffered I/O is enabled, it indicates the buffer size. By default, it is set to 8kb.
Q 8 - Which of the following DatePattern configuration of DailyRollingFileAppender rolls over the logs at midnight each day?
Answer : B
Explanation
'.' yyyy-MM-dd − Roll over at midnight each day. This is the default value.
Q 9 - The layout layer of log4j architecture provides objects which are used to format logging information in different styles.
Answer : B
Explanation
true − The layout layer of log4j architecture provides objects which are used to format logging information in different styles. It provides support to appender objects before publishing logging information.
Q 10 - The Filter objects can analyze logging information beyond level matching and decide whether logging requests should be handled by a particular Appender or ignored.
Answer : A
Explanation
true − The Filter objects can analyze logging information beyond level matching and decide whether logging requests should be handled by a particular Appender or ignored.