log4j vs logback [英] log4j vs logback

查看:169
本文介绍了log4j vs logback的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在自制包装器后面使用log4j。我们现在计划使用它的更多功能。

We are using log4j behind a selfmade wrapper. We plan to use much more features of it now.

我们应该更新为logback吗?

Should we update to logback ?

(我的意思是框架不是像SLF4J那样的外观)

(I mean the framework not a facade like SLF4J)

推荐答案

Logback本机实现SLF4J API。这意味着如果您使用的是logback,那么您实际上正在使用SLF4J API。理论上,您可以直接使用logback API的内部进行日志记录,但这是非常不鼓励的。记录器上的所有logback文档和示例都是根据SLF4J API编写的。

Logback natively implements the SLF4J API. This means that if you are using logback, you are actually using the SLF4J API. You could theoretically use the internals of the logback API directly for logging, but that is highly discouraged. All logback documentation and examples on loggers are written in terms of the SLF4J API.

所以通过使用logback,你实际上是在使用SLF4J,如果由于某种原因你想切换回log4j,你可以在几分钟内完成,只需删除slf4j -log4j12.jar到你的类路径上。

So by using logback, you'd be actually using SLF4J and if for any reason you wanted to switch back to log4j, you could do so within minutes by simply dropping slf4j-log4j12.jar onto your class path.

从logback迁移到log4j时,特定于logback的部分,特别是那些包含在 logback.xml 配置中的部分仍然需要将文件迁移到其log4j等效文件,即 log4j.properties 。在向另一个方向迁移时,需要将log4j配置(即 log4j.properties )转换为其等效的logback。有一个在线工具。迁移配置文件所涉及的工作量 小于迁移所有软件源代码及其依赖项中传播的记录器调用所需的工作量。

When migrating from logback to log4j, logback specific parts, specifically those contained in logback.xml configuration file would still need to be migrated to its log4j equivalent, i.e. log4j.properties. When migrating in the other direction, log4j configuration, i.e. log4j.properties, would need to be converted to its logback equivalent. There is an on-line tool for that. The amount of work involved in migrating configuration files is much less than the work required to migrate logger calls disseminated throughout all your software's source code and its dependencies.

这篇关于log4j vs logback的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆