Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

Log4j Interview Questions and Answers For Graduates Part-1

Be First!

log4j1.What is log4j?
log4j is a reliable, fast and flexible logging framework (APIs) written in Java, which is distributed under the Apache Software License.

log4j has been ported to the C, C++, C#, Perl, Python, Ruby, and Eiffel languages.

log4j is highly configurable through external configuration files at runtime. It views the logging process in terms of levels of priorities and offers mechanisms to direct logging information to a great variety of destinations, such as a database, file, console, UNIX Syslog, etc.

2.What are the components of log4j?
log4j has three main components −

loggers: Responsible for capturing logging information.

appenders: Responsible for publishing logging information to various preferred destinations.

layouts: Responsible for formatting logging information in different styles.

3.What are the features of log4j?
Following are features of log4j −

It is thread-safe.

It is optimized for speed.

It is based on a named logger hierarchy.

It supports multiple output appenders per logger.

It supports internationalization.

It is not restricted to a predefined set of facilities.

Logging behavior can be set at runtime using a configuration file.

It is designed to handle Java Exceptions from the start.

It uses multiple levels, namely ALL, TRACE, DEBUG, INFO, WARN, ERROR and FATAL.

The format of the log output can be easily changed by extending the Layout class.

The target of the log output as well as the writing strategy can be altered by implementations of the Appender interface.

It is fail-stop. However, although it certainly strives to ensure delivery, log4j does not guarantee that each log statement will be delivered to its destination.

4.What are Pros and Cons of Logging?
Following are the Pros and Cons of Logging −

Logging is an important component of the software development. A well-written logging code offers quick debugging, easy maintenance, and structured storage of an application’s runtime information.

Logging does have its drawbacks also. It can slow down an application. If too verbose, it can cause scrolling blindness. To alleviate these concerns, log4j is designed to be reliable, fast and extensible.

Since logging is rarely the main focus of an application, the log4j API strives to be simple to understand and to use.

5.What is the purpose of Logger object?
Logger Object − 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.

6.What is the purpose of Layout object?
Layout Object − 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.

Layout objects play an important role in publishing logging information in a way that is human-readable and reusable.

7.What is the purpose of Appender object?
Appender Object − This is a lower-level layer of log4j architecture which provides Appender objects. The Appender object is responsible for publishing logging information to various preferred destinations such as a database, file, console, UNIX Syslog, etc.

8.What is the purpose of Level object?
Level Object – 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.

9.What is the purpose of Filter object?
Filter Object − The Filter object is used to analyze logging information and make further decisions on whether that information should be logged or not. An Appender objects can have several Filter objects associated with them. If logging information is passed to a particular Appender object, all the Filter objects associated with that Appender need to approve the logging information before it can be published to the attached destination.

10.What is the purpose of ObjectRenderer object?
ObjectRenderer − The ObjectRenderer object is specialized in providing a String representation of different objects passed to the logging framework. This object is used by Layout objects to prepare the final logging information.

(140)

Previous
Next

Leave a Reply