Olete.in
Articles
Mock Tests
🧪 log4j MCQ Quiz Hub
Log4j MCQ Quiz
Choose a topic to test your knowledge and improve your log4j skills
1. Which of the following method of logger print a log message in info mode?
public void debug(Object message)
public void error(Object message)
public void fatal(Object message)
public void info(Object message)
2. Mention what are the different types of Appenders?
ConsoleAppender logs to standard output
FileAppender prints logs to some file
Rolling file appender to a file with maximum size
All of the these
3. Which of the following log4j objects are responsible for formatting logging information in different styles?
loggers
appenders
layouts
None of above
4. Which of the following is correct about target in Appender?
Appender uses the target and the conversion pattern associated with them to format the logging information.
The target may be a console, a file, or another item depending on the appender.
The target is required to control the filtration of the log messages.
Appender can have a target associated with it independent of the logger leve
5. Which of the following method of logger print a log message in trace mode?
public void warn(Object message)
public void trace(Object message)
public void fatal(Object message)
public void info(Object message)
6. Which of the following is true about PatternLayout object?
If you want to generate your logging information in a particular format based on a pattern, then you can use org.apache.log4j.PatternLayout to format your logging information.
The PatternLayout class extends the abstract org.apache.log4j.Layout class and overrides the format() method to structure the logging information according to a supplied pattern.
Both of the above.
None of above
7. What is the purpose of p character used in the conversionPattern of PatternLayout object?
Outputs the platform dependent line separator character or characters.
Used to output the priority of the logging event.
Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event.
Used to output the name of the thread that generated the logging event.
8. What is the purpose of % character used in the conversionPattern of PatternLayout object?
Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.
Used to print the information stored in the MDC against the key.
Used to print a % sign.
Used to Left pad with spaces if the category name is less than 20 characters long.
9. What is the purpose of immediateFlush configuration of FileAppender?
output stream to the file being flushed with each append operation.
to set the platform-specific encoding scheme.
to set the threshold level for this appender.
to set the name of the log file.
10. Which of the following DatePattern configuration of DailyRollingFileAppender rolls over the logs at midnight each day?
'.' yyyy-MM
'.' yyyy-MM-dd
'.' yyyy-MM-dd-a
'.' yyyy-MM-dd-HH
11. Which of the following is correct about LogManager object?
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.
Both of the above.
None of the above.
12. Method creates a mock object from a domain class.
mockForConstraintsTests
mockForConstraints
all of the mentioned
None of the mentioned
13. Grails application logging can be configured using
creating custom appenders
logging levels
console output
all of the mentioned
14. An appender that logs to a JDBC connection.
jdbc
console
file
rollingFile
15. Which of the following is true about PatternLayout object?
The PatternLayout class extends the abstract org.apache.log4j.Layout class and overrides the format() method to structure the logging information according to a supplied pattern e
The PatternLayout class extends the abstract org.apache.log4j.Layout class and overrides the format() method to structure the logging information according to a supplied pattern
Both of the abovecorrect
None of the above
16. Which of the following set the location information for the logging event using HTMLLayout?
HTMLLayout.setContentType(String)
HTMLLayout.setLocationInfo(String)
HTMLLayout.setTitle(String)
None of the above
17. Log4J also has the following logging level
fatal
error
warning
all of the mentioned
18. To offer versatile logging functionality
loggers
appenders
all of the mentioned
None of the mentioned
19. What license is Log4j distributed under?
Apache License 2.0
Closed Source server, GPL client
Shareware
Originally Proprietary, BSD license since 2000
20. Who developed Log4j?
Mozilla Foundation
Apache Software Foundation
Sony Creative Software
Blender Foundation
Submit