简体   繁体   English

log4j、slf4j 和 logback 有什么区别?

[英]What is the difference between log4j, slf4j and logback?

I am little bit confused by these three logger libraries.我对这三个记录器库有点困惑。 It seems like that they can do the similar thing in java logging...似乎他们可以在java日志中做类似的事情......

Check out their home pages:查看他们的主页:

SLF4J - The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction 1 for various logging frameworks (eg java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time. SLF4J - Java 的简单日志外观 (SLF4J) 作为各种日志框架(例如 java.util.logging、logback、log4j)的简单外观或抽象1 ,允许最终用户在部署时插入所需的日志框架。

1) It is not itself a logging library, but a generic interface to one of many logging libraries. 1) 它本身不是一个日志库,而是许多日志库之一的通用接口。

Log4j 1.2 - Welcome to Apache log4j, a logging library for Java. Log4j 1.2 - 欢迎使用 Apache log4j,一个 Java日志库

Logback - Logback is intended as a successor to the popular log4j project, picking up where log4j leaves off. Logback - Logback旨在作为流行的 log4j项目的继承者,从 log4j停止的地方开始。

Log4j 2 - Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture. Log4j 2 - Apache Log4j 2 是对 Log4j升级,它比其前身 Log4j 1.x 提供了重大改进,并提供了 Logback 中可用的许多改进,同时修复了 Logback 架构中的一些固有问题。

At least, that's what they all say of themselves.至少,他们都是这样评价自己的。

This link : https://medium.com/@krishankantsinghal/logback-slf4j-log4j2-understanding-them-and-learn-how-to-use-d33deedd0c46此链接: https : //medium.com/@krishankantsinghal/logback-slf4j-log4j2-understanding-them-and-learn-how-to-use-d33deedd0c46

Explains the differences in detail.详细解释差异。

Quoting from there从那里引用

Slf4j Slf4j

So Basically Simple Logging Facade for Java serves as a simple facade or abstraction for various logging frameworks allowing the end user to plug in the desired logging framework at deployment time.因此,Java 的基本简单日志门面充当各种日志框架的简单门面或抽象,允许最终用户在部署时插入所需的日志框架。

log4j2日志4j2

Log4j,Logback and java.util.Logger are logging libraries which actually write the logs and have their own pros and cons. Log4j、Logback 和 java.util.Logger 是实际写入日志的日志库,它们各有优缺点。 As industry standards are Log4j2 and logback行业标准是 Log4j2 和 logback

I would recommend going through the blog.我会建议通过博客。 It provides all the glory details how both are used with adapter.它提供了如何与适配器一起使用的所有荣耀细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM