log4j Overview - Log4j

What is log4j Overview?

log4j is a dependable, fast and flexible logging framework (APIs) written in Java, which is spread under the Apache Software License.
log4j has been ported to the C, C++, C#, Perl, Python, Ruby, and Eiffel languages.

log4j is extremely configurable over external configuration files at runtime. It outlooks 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.

log4j has three main components:

  • loggers: Liable for capturing logging information.
  • appenders: Liable for publishing logging information to various preferred destinations.
  • layouts: Liable for formatting logging information in different styles.

History of log4j

  • Started in early 1996 as tracing API for the E.U. SEMPER (Secure Electronic Marketplace for Europe) project.
  • After uncountable improvements and numerous incarnations, the initial API has changed to develop log4j, a general logging package for Java.
  • The package is spread under the Apache Software License, a full-fledged open source license certified by the open source initiative.
  • The latest log4j version, including its full-source code, class files, and documentation can be found at http://logging.apache.org/log4j/.

log4j Features

  • 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.

Pros and Cons of Logging

  • Logging is a significant module of the software development. A good-written logging code deals quick debugging, easy maintenance, and structured storage of an application's runtime information.
  • Logging does have its disadvantages also. It can slow down an application. If too verbose, it can root scrolling blindness. To ease these concerns, log4j is designed to be dependable, fast and extensible.
  • Meanwhile logging is seldom the key emphasis of an application, the log4j API strives to be simple to understand and to use.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Log4j Topics