- 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.
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 Appender object?
A - This is a lower-level layer of log4j architecture which provides Appender objects.
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 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 p 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 : B
Explanation
p − Used to output the priority of the logging event.
Q 6 - What is the intent of %-20.30c format modifier?
C - Truncate from the beginning if the category name is longer than 20 characters.
Answer : B
Explanation
%-20.30c − Right pad with spaces if the category name is shorter than 20 characters. However, if the category name is longer than 30 characters, then truncate from the beginning.
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 - 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 - The Appender object is responsible for publishing logging information to various preferred destinations such as a database, file, console, UNIX Syslog, etc.
Answer : B
Explanation
true − The Appender object is responsible for publishing logging information to various preferred destinations such as a database, file, console, UNIX Syslog, etc.
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.