Skip to Content, PHP, MySQL, Javascript, Ajax, Htacces

Log4j Interview Questions and Answers For Graduates Part-4

Be First!

log4j31.What is purpose of FATAL log level?
FATAL − Designates very severe error events that will presumably lead the application to abort.

32.What is purpose of INFO log level?
INFO − Designates informational messages that highlight the progress of the application at coarse-grained level.

33.What is purpose of OFF log level?
OFF − The highest possible rank and is intended to turn off logging.

34.What is purpose of TRACE log level?
TRACE − Designates finer-grained informational events than the DEBUG.

35.What is purpose of WARN log level?
WARN − Designates potentially harmful situations.

36.How do Levels Works?
A log request of level p in a logger with level q is enabled if p >= q. This rule is at the heart of log4j. It assumes that levels are ordered. For the standard levels, we have ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF.

37.How will you define a root logger turning DEBUG mode off?
Following syntax defines the root logger with WARN mode turning DEBUG mode off.

# Define the root logger with appender file
log = /usr/home/log4j
log4j.rootLogger = WARN, FILE

38.What is the purpose of 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.

39.What is the purpose of c character used in the conversionPattern of PatternLayout object?
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”.

40.What is the purpose of C character used in the conversionPattern of PatternLayout object?
C − Used to output the fully qualified class name of the caller issuing the logging request. For example, for the class name. “”, the pattern %C{1} will output “SomeClass”.



Leave a Reply