- 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 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 method of logger print a log message in fatal mode?
A - public void debug(Object message)
B - public void error(Object message)
Answer : C
Explanation
public void fatal(Object message) of Logger class prints messages with the level Level.FATAL.
Q 4 - What is the purpose of c 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 : A
Explanation
c − Used to output the category of the logging event. For example, for the category name "a.b.c" the pattern %c{2} will output "b.c".
Q 5 - What is the purpose of m character used in the conversionPattern of PatternLayout object?
A - Used to output location information of the caller which generated the logging event.
B - Used to output the line number from where the logging request was issued.
C - Used to output the application supplied message associated with the logging event.
D - Used to output the method name where the logging request was issued.
Answer : C
Explanation
m − Used to output the application supplied message associated with 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 : C
Explanation
%.20c − Truncate from the beginning if the category name is longer than 20 characters.
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 on the first day of each week depending upon the locale?
Answer : B
Explanation
'.' yyyy-ww − Roll over on the first day of each week depending upon the locale.
Q 9 - What is the purpose of driver 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 : A
Explanation
driver − Sets the driver class to the specified string. If no driver class is specified, it defaults to sun.jdbc.odbc.JdbcOdbcDriver.
Q 10 - By default, the LogManager looks for a file named log4j.properties in the CLASSPATH.
Answer : B
Explanation
true − By default, the LogManager looks for a file named log4j.properties in the CLASSPATH.