![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?
B - log4j has been ported to the C, C++, C#, Perl, Python, Ruby, and Eiffel languages.
C - log4j is highly configurable through external configuration files at runtime.
Answer : D
Explanation
All 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 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 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 F character used in the conversionPattern of PatternLayout object?
A - Used to output the category of the logging event.
B - Used to output the fully qualified class name of the caller issuing the logging request.
C - Used to output the date of the logging event.
D - Used to output the file name where the logging request was issued.
Answer : D
Explanation
F − Used to output the file name where the logging request was issued.
Q 6 - Which of the following is correct about org.apache.log4j.HTMLLayout class?
B - It provides the name of the thread that invoked the logging request.
C - It provides the level associated with this logging request.
Answer : D
Explanation
All of the above options are correct.
Q 7 - Which of the following set the location information for the logging event using HTMLLayout?
A - HTMLLayout.setContentType(String)
B - HTMLLayout.setLocationInfo(String)
Answer : B
Explanation
HTMLLayout.setLocationInfo(String) − Sets the location information for the logging event. Default is false.
Q 8 - Which of the following DatePattern configuration of DailyRollingFileAppender rolls over the logs at the end of each month and at the beginning of the next month?
Answer : A
Explanation
'.' yyyy-MM − Roll over at the end of each month and at the beginning of the next month.
Q 9 - How will you put the logs in database using log4j??
Answer : A
Explanation
The log4j API provides the org.apache.log4j.jdbc.JDBCAppender object, which can put logging information in a specified database.
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.
To Continue Learning Please Login