
- log4j Tutorial
- log4j - Home
- log4j - Overview
- log4j - Installation
- log4j - Architecture
- log4j - Configuration
- log4j - Sample Program
- log4j - Logging Methods
- log4j - Logging Levels
- log4j - Log Formatting
- log4j - Logging in Files
- log4j - Logging in Database
- log4j Useful Resources
- log4j - Questions and Answers
- log4j - Quick Guide
- log4j - Useful Resources
- log4j - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Logger object?
A - The top-level layer of log4j architecture is the Logger which provides the Logger object.
Answer : C
Explanation
Both of the above options are correct.
Q 2 - Which of the following is correct about target in Appender?
B - The target may be a console, a file, or another item depending on the appender.
C - The target is required to control the filtration of the log messages.
D - Appender can have a target associated with it independent of the logger level.
Answer : B
Explanation
target − The target may be a console, a file, or another item depending on the appender.
Q 3 - Which of the following method of logger print a log message in trace mode?
A - public void warn(Object message)
B - public void trace(Object message)
Answer : B
Explanation
public void trace(Object message) of Logger class prints messages with the level Level.TRACE.
Q 4 - Which of the following level designates all levels including custom levels?
Answer : D
Explanation
ALL − All levels including custom levels.
Q 5 - What is the purpose of L 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 : B
Explanation
L − Used to output the line number from where the logging request was issued.
Q 6 - What is the purpose of % 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 : C
Explanation
% − The literal percent sign. %% will print a % sign.
Q 7 - Which of the following set title for the HTML file using HTMLLayout?
A - HTMLLayout.setContentType(String)
B - HTMLLayout.setLocationInfo(String)
Answer : C
Explanation
HTMLLayout.setTitle(String) − Sets the title for the HTML file. Default is log4j Log Messages.
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 log4j.properties file is a log4j configuration file which keeps properties in key-value pairs.
Answer : B
Explanation
true − The log4j.properties file is a log4j configuration file which keeps properties in key-value pairs. By default, the LogManager looks for a file named log4j.properties in the CLASSPATH.