Transferred from: http://www.codeceo.com/article/8-java-log-framework.html
As a Java programmer, we have developed many Java applications, including desktop applications, Web applications, and mobile applications. However, the log system is essential for a mature Java application, in the development and debugging phase, the log can help us to locate the bug better and faster, during the maintenance phase, the log system can help us to record most of the abnormal information, so as to help us better improve the system. This article will share some of the most common Java log framework components used by Java programmers.
1. log4j– Most popular Java log components
Log4j is a Java-based open source log component, log4j is very powerful, we can output log information to the console, file, user interface, can also output to the operating system's event logger and some system resident process. It is also worth mentioning that log4j allows you to customize the log format and log level very easily, helping developers to control the log information in all directions.
Official website: http://logging.apache.org/log4j/2.x/
Here is a simple example of using log4j:
Package Com.mai.test;import Org.apache.log4j.logger;import Org.apache.log4j.propertyconfigurator;public class log4jtest {public static void main (string[] args) {Logger log = Logger.getlogger (Log4jtest.class); Propertyconfigurator.configure ("Src/log4j.properties"), Log.debug ("Yes,debug"), Log.info ("Yes,info"); Log.error (" Yes,error "); Log.warn (" Yes,warn ");}}
2. Gclogviewer–java Log Viewing tool
Gclogviewer is a GC log visualizer that supports JDK 6, and the Gclogviewer supports a trend graph of GC generation based on GC log, as well as the data trend graph needed to generate tuning recommendations, compared to Gcviewer.
Official website: http://code.google.com/p/gclogviewer/
3. slf4j– API-based Java log framework
SLF4J provides a simple, unified logging interface that allows developers to implement the logging functionality only when configured and deployed. Logging API implementation can choose to directly implement SLF4J loging APIs such as: Nlog4j, Simplelogger. It is also possible to develop appropriate adapters such as Log4jloggeradapter, jdk14loggeradapter through the API implementations provided by SLF4J.
Official website: http://www.slf4j.org/
4. Flume–apache Log Server
Previously described are a number of logging tools, Flume is a log analysis system, Flume is distributed, it has a very flexible architecture to collect, aggregate and move a large number of log data, and provide a reliable, fault-tolerant system architecture.
Official website: http://flume.apache.org/
5. zlogfabric– Log Storage System
Zlogfabric is an integrated cross-platform logging solution that collects log information from individual applications to a centralized system through the messaging system. The modular design allows the server to store, forward, alert, and generate log statistics for logs.
Zlogfabric can collect data from files, syslog, log4j, log4net, and Windows events.
Official website: http://www.zlogfabric.com/
6. Logstash–java Log Management tool
Logstash is a very powerful log management tool that enables you to transfer, process, manage, and retrieve logs, and provides web interfaces for developers to count and query log information with Logstash.
Official website: http://www.logstash.net/
7, Commons Logging
The implementation of the Commons logging does not depend on the specific log Implementation tool, but provides some abstract interfaces for log operations, and it encapsulates other logging tools such as log4j, Avalon Logkit, and JDK 1.4.
Official website: http://commons.apache.org/proper/commons-logging/
8, Darks Logs
Darks logs and log4j are similar, but also for Java, Android and other projects, but darks logs the use of more simple, and the Android side has made a great improvement. Darks logs adds appender to SQLite's log save. It is designed to address issues such as the inability of Android logs to control frequently used operations such as log levels, formatting, saving or displaying targets.
Official website: https://github.com/liulhdarks/darks-logs
8 Java Log Frameworks most commonly used by Java programmers