本文介绍了你发现java.util.logging足够吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据标题,您是否找到了足以满足您需求的默认Java日志框架?

Per the title, do you find the default Java logging framework sufficient for your needs?

您是否使用其他日志记录服务,例如或其他人?如果是这样,为什么?
我想听听你对不同类型项目中的日志记录要求的任何建议,以及何时集成框架实际上是必要和/或有用的。

Do you use alternative logging services such as log4j or others? If so, why?I'd like to hear any advice you have regarding logging requirements in different types of projects, and when integrating frameworks is actually necessary and/or useful.

推荐答案

使用第三方库记录依赖关系



在大多数情况下,Java JDK日志记录本身并不足够。但是,如果您有一个使用多个开源第三方库的大型项目,您将很快发现它们中的许多都具有不同的日志记录依赖性。

Logging Dependencies with Third Party Libraries

Java JDK logging in most cases is not insufficient by itself. However, if you have a large project that uses multiple open-source third party libraries, you will quickly discover that many of them have disparate logging dependencies.

它们在这些中需要从日志记录实现中抽象日志API变得很重要的情况。我建议使用或(使用slf4j API)作为您的API,如果您想坚持使用Java JDK日志记录,您仍然可以! Slf4j可以毫无问题地输出到许多不同的记录器实现。

It is in these cases where the need to abstract your logging API from your logging implementation become important. I recommend using slf4j or logback (uses the slf4j API) as your API and if you want to stick with Java JDK logging, you still can! Slf4j can output to many different logger implementations with no problems.

在最近的项目中发生了它的有用性的一个具体例子:我们需要使用需要log4j的第三方库,但是我们不希望并排运行两个日志框架,所以我们使用了slf4j log4j api包装器库,问题解决了。

A concrete example of its usefulness happened during a recent project: we needed to use third-party libs that needed log4j, but we did not want to run two logging frameworks side by side, so we used the slf4j log4j api wrapper libs and the problem was solved.

总结一下,Java JDK日志记录很好,但是我的第三方库中使用的标准化API将为您节省时间。试着想象重构每个日志声明!

In summary, Java JDK logging is fine, but a standardized API that is used in my third party libraries will save you time in the long run. Just try to imagine refactoring every logging statement!

这篇关于你发现java.util.logging足够吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 07:34