
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 log4j objects are responsible for formatting logging information in different styles?
Answer : C
Explanation
layouts − Responsible for formatting logging information in different styles.
Q 2 - Which of the following is correct about Level object?
A - The Level object defines the granularity and priority of any logging information.
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 informational messages that highlight the progress of the application at coarse-grained level?
Answer : D
Explanation
INFO − Designates informational messages that highlight the progress of the application at coarse-grained level.
Q 5 - What is the purpose of t 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 : D
Explanation
t − Used to output the name of the thread that generated the logging event.
Q 6 - What is the intent of %20c format modifier?
A - Left pad with spaces if the category name is less than 20 characters long.
B - Right pad with spaces if the category name is less than 20 characters long.
C - Truncate from the beginning if the category name is longer than 20 characters.
Answer : A
Explanation
%20c − Left pad with spaces if the category name is less than 20 characters long.
Q 7 - What is the purpose of immediateFlush configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : A
Explanation
immediateFlush − This flag is by default set to true, which means the output stream to the file being flushed with each append operation.
Q 8 - What is the purpose of DatePattern configuration of DailyRollingFileAppender?
A - to set the critical size of the file above which the file will be rolled.
B - to set the number of backup files to be created.
Answer : C
Explanation
DatePattern − This indicates when to roll over the file and the naming convention to be followed. By default, roll over is performed at midnight each day.
Q 9 - The top-level layer of log4j architecture is the Logger which provides the Logger object.
Answer : A
Explanation
true − The top-level layer of log4j architecture is the Logger which provides the Logger object. The Logger object is responsible for capturing logging information and they are stored in a namespace hierarchy.
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.