Log frameworks

The most widely used logging framework is Apachelog4j. It currently has a second version that is a total rewrite of the first version. It is very versatile and has many appenders and formatters. The configuration of log4j can be in XML or properties file format, and it can also be configured through API.

The author of log4j version 1 created a new logging framework: slf4j. This logging library is essentially a façade that can be used together with any other logging framework. Thus, when you use slf4j in a library you develop, and your code is added to a program as a dependency that uses a different logging framework, it is easy to configure slf4j to send the logs to the loggers of the other framework. Thus, the logs will be handled together and not in separate file, which is desirable to decrease the cost of operation. When developing your library code or an application that uses slf4j, there is no need to select another log framework to slf4j. It has its own simple implementation called backlog.

Apache Commons Logging is also a façade with its own logging implementation if nothing else fails. The major difference from slf4j is that it is more flexible in configuration and what underlying logging to use, and it implements a run-time algorithm to discover which logging framework is available and is to be used. The industry best practice shows that this flexibility, which also comes with higher complexity and cost, is not needed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.237.29