- 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?
B - It is optimized for speed.
Answer : D
Explanation
All of the above options are correct.
Q 2 - Which of the following is correct about log4j.properties?
B - By default, the LogManager looks for a file named log4j.properties in the CLASSPATH.
Answer : C
Explanation
Both of the above options are correct.
Q 3 - Which of the following is correct about threshold in Appender?
B - The threshold may be a console, a file, or another item depending on the appender.
C - The threshold is required to control the filtration of the log messages.
D - Appender can have a threshold associated with it independent of the logger level.
Answer : D
Explanation
threshold − Appender can have a threshold level associated with it independent of the logger level. The Appender ignores any logging messages that have a level lower than the threshold level.
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 M character used in the conversionPattern of PatternLayout object?
A - Used to output location information of the caller which generated the logging event.
B - Used to output the line number from where the logging request was issued.
C - Used to output the application supplied message associated with the logging event.
D - Used to output the method name where the logging request was issued.
Answer : D
Explanation
M − Used to output the method name where the logging request was issued.
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 : B
Explanation
X − The X conversion character is followed by the key for the MDC. For example, X{clientIP} will print the information stored in the MDC against the key clientIP.
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 midday and midnight of each day?
Answer : C
Explanation
'.' yyyy-MM-dd-a − Roll over at midday and midnight of each day.
Q 9 - What is the purpose of user configuration of JDBCAppender?
B - to set the database user name.
C - to specify the SQL statement to be executed every time a logging event occurs.
Answer : B
Explanation
user − Sets the database user name.
Q 10 - Appender can have a threshold level associated with it independent of the logger level.
Answer : A
Explanation
true − Appender can have a threshold level associated with it independent of the logger level. The Appender ignores any logging messages that have a level lower than the threshold level.