- 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 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 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 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 d 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 : C
Explanation
d − Used to output the date of the logging event. For example, %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}.
Q 6 - What is the purpose of X 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 : B
Explanation
X − The X conversion character is followed by the key for the MDC. For example, X{clientIP} will print the information stored in the MDC against the key clientIP.
Q 7 - What is the purpose of immediateFlush configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : A
Explanation
immediateFlush − This flag is by default set to true, which means the output stream to the file being flushed with each append operation.
Q 8 - What is the purpose of maxFileSize configuration of RollingFileAppender?
A - to set the critical size of the file above which the file will be rolled.
Answer : A
Explanation
maxFileSize − This is the critical size of the file above which the file will be rolled.
Q 9 - What is the purpose of user configuration of JDBCAppender?
B - to set the database user name.
C - to specify the SQL statement to be executed every time a logging event occurs.
Answer : B
Explanation
user − Sets the database user name.
Q 10 - The Logger object is responsible for publishing logging information to various preferred destinations such as a database, file, console, UNIX Syslog, etc.
Answer : B
Explanation
false − The Appender object is responsible for publishing logging information to various preferred destinations such as a database, file, console, UNIX Syslog, etc.