- 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 Mock Test
This section presents you various set of Mock Tests related to log4j Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
log4j Mock Test IV
Q 1 - 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 2 - 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 3 - Which of the following DatePattern configuration of DailyRollingFileAppender rolls over the logs at the top of every hour?
Answer : D
Explanation
'.' yyyy-MM-dd-HH − Roll over at the top of every hour.
Q 4 - Which of the following DatePattern configuration of DailyRollingFileAppender rolls over the logs every minute?
Answer : A
Explanation
'.' yyyy-MM-dd-HH-mm − Roll over every minute.
Q 5 - 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 6 - 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 7 - 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 8 - What is the purpose of password 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 : B
Explanation
password − Sets the database password.
Q 9 - What is the purpose of sql 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 : C
Explanation
sql − Specifies the SQL statement to be executed every time a logging event occurs. This could be INSERT, UPDATE, or DELETE.
Q 10 - What is the purpose of URL configuration of JDBCAppender?
B - to set the database password.
C - to specify the SQL statement to be executed every time a logging event occurs.
Answer : A
Explanation
URL − Sets the JDBC URL.
Q 11 - 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 13 - 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 14 - The layout layer of log4j architecture provides objects which are used to format logging information in different styles.
Answer : B
Explanation
true − The layout layer of log4j architecture provides objects which are used to format logging information in different styles. It provides support to appender objects before publishing logging information.
Q 15 - 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 16 - 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.
Q 17 - 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.
Answer : A
Explanation
true − The LogManager object manages the logging framework. It is responsible for reading the initial configuration parameters from a system-wide configuration file or a configuration class.
Q 19 - The log4j.properties file is a log4j configuration file which keeps properties in key-value pairs.
Answer : B
Explanation
true − The log4j.properties file is a log4j configuration file which keeps properties in key-value pairs. By default, the LogManager looks for a file named log4j.properties in the CLASSPATH.
Q 20 - 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.
Q 21 - Appender uses the Layout objects and the conversion pattern associated with them to format the logging information.
Answer : B
Explanation
true − Appender uses the Layout objects and the conversion pattern associated with them to format the logging information.
Q 22 - Logger uses the Layout objects and the conversion pattern associated with them to format the logging information.
Answer : B
Explanation
false − Appender uses the Layout objects and the conversion pattern associated with them to format the logging information.
Q 23 - The target may be a console, a file, or another item depending on the appender.
Answer : A
Explanation
true − The target may be a console, a file, or another item depending on the appender.
Q 24 - Appender can have a threshold level associated with it independent of the logger level.
Answer : A
Explanation
true − Appender can have a threshold level associated with it independent of the logger level. The Appender ignores any logging messages that have a level lower than the threshold level.
Q 25 - 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.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | B |
2 | C |
3 | D |
4 | A |
5 | B |
6 | A |
7 | A |
8 | B |
9 | C |
10 | A |
11 | B |
12 | A |
13 | A |
14 | B |
15 | B |
16 | B |
17 | A |
18 | A |
19 | B |
20 | B |
21 | B |
22 | B |
23 | A |
24 | A |
25 | A |