简体   繁体   English

在单个项目中使用log4j和slf4j-这是一个好主意吗?

[英]log4j and slf4j in single project - is this a good idea?

In our project we have been using log4j for a long time. 在我们的项目中,我们已经使用log4j很长时间了。 And it served our purposes well. 它很好地满足了我们的目的。

We have a need now to use a query builder, for database queries. 现在,我们需要使用查询构建器来进行数据库查询。 We decided to try out either querydsl or jooq . 我们决定尝试使用querydsljooq However, both of them seem to demand slf4j as a logging library. 但是,它们似乎都需要slf4j作为日志记录库。

I could simply include that as the maven dependency, but are there any pitfalls? 我可以简单地将其作为Maven依赖项包括在内,但是有任何陷阱吗? Can log4j conflict with slf4j and generate some unpredicted behaviour? log4j是否可以与slf4j冲突并生成某些不可预测的行为?

From SLF4J website : 从SLF4J网站:

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

So SLF4J is just a facade and will use log4j behind... 因此SLF4J只是一个外观,将在后面使用log4j ...

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

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