- log4j - Home
- log4j - Overview
- log4j - Installation
- log4j - Architecture
- log4j - Configuration
- log4j - Sample Program
- log4j - Logging Methods
- log4j - Logging Levels
- log4j - ConsoleAppender
- log4j - Logging in Database
Log4j - Formatting Layouts
- log4j - Log Formatting
- log4j - CSV Parameter Layout
- log4j - CSV Log Event Layout
- log4j - HTML Layout
- log4j - Pattern Layout
- log4j - Json Template Layout
Log4j - File Appenders
- log4j - Logging in Files
- log4j - FileAppender
- log4j - Separate Folder per Month
- log4j - Daily log File Generation
log4j Resources
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 log4j.properties?
B - By default, the LogManager looks for a file named log4j.properties in the CLASSPATH.
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 designates potentially harmful situations?
Answer : C
Explanation
WARN − Designates potentially harmful situations.
Q 5 - What is the purpose of r 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 : C
Explanation
r − Used to output the number of milliseconds elapsed from the construction of the layout until the creation of 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 : B
Explanation
%-20c − Right pad with spaces if the category name is less than 20 characters long.
Q 7 - What is the purpose of encoding configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : B
Explanation
encoding − It is possible to use any character-encoding. By default, it is the platform-specific encoding scheme.
Q 8 - Which of the following DatePattern configuration of DailyRollingFileAppender rolls over the logs at midnight each day?
Answer : B
Explanation
'.' yyyy-MM-dd − Roll over at midnight each day. This is the default value.
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 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.