![log4j Tutorial](/log4j/images/log4j-mini-logo.jpg)
- 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
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.
![Questions and Answers](/images/questions_and_answers.png)
Q 1 - Which of the following is correct about log4j?
C - log4j does not guarantee that each log statement will be delivered to its destination.
Answer : D
Explanation
All of the above options are correct.
Q 2 - Which of the following is correct about ObjectRenderer object?
B - This object is used by Layout objects to prepare the final logging information.
Answer : C
Explanation
Both of the above options are correct.
Q 3 - Which of the following is correct about filter in Appender?
B - The filter may be a console, a file, or another item depending on the appender.
C - The filter is required to control the filtration of the log messages.
D - Appender can have a filter associated with it independent of the logger level.
Answer : A
Explanation
filter − The Filter objects can analyze logging information beyond level matching and decide whether logging requests should be handled by a particular Appender or ignored.
Q 4 - Which of the following level is intended to turn off logging?
Answer : A
Explanation
OFF − The highest possible rank and is intended to turn off logging.
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 % 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 - What is the purpose of Filename configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : D
Explanation
Filename − The name of the log file.
Q 8 - What is the purpose of maxBackupIndex configuration of RollingFileAppender?
A - to set the critical size of the file above which the file will be rolled.
Answer : B
Explanation
maxBackupIndex − This property denotes the number of backup files to be created.
Q 9 - What is the purpose of sql configuration of JDBCAppender?
A - to set the driver class to the specified string.
B - to set the database password.
C - to specify the SQL statement to be executed every time a logging event occurs.
Answer : C
Explanation
sql − Specifies the SQL statement to be executed every time a logging event occurs. This could be INSERT, UPDATE, or DELETE.
Q 10 - The Level object defines the granularity and priority of any logging information.
Answer : A
Explanation
true − The Level object defines the granularity and priority of any logging information. There are seven levels of logging defined within the API: OFF, DEBUG, INFO, ERROR, WARN, FATAL, and ALL.