java - 为将在多个项目之间共享的 Java 库设置日志记录的最佳方法?

标签 java logging

如果我正在创建一个新的 java 项目,它将成为一个将被多个项目使用的库,那么在其中设置日志记录的最佳方法是什么?

本质上,问题的出现是因为每个人都在项目中使用不同的日志记录库(log4j、common-logging 等),我不想让其他人在使用我的库时难以使用他们想要的东西。

目标是为我的库中的类提供日志记录,同时为使用它的其他项目提供一种轻松的方式来使用他们想要的任何日志记录框架。

最佳答案

我想你想要的是SLF4J .

The separation of the client API from the logging backend reduces the coupling between an application and any particular logging framework. This can make it easier to integrate with existing or third-party code or to deliver code into other projects that have already made a choice of logging backend.

关于java - 为将在多个项目之间共享的 Java 库设置日志记录的最佳方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7367103/

相关文章:

java - JSTL fmt :message and resource bundle

Java Elasticsearch 数据库测试

java - 确保在 logback 中应用程序关闭之前发送错误 SMTP

java - 我没有在 struts2 中使用 freemarker,但我看到 freemarker 生成了很多日志记录

Android 日志级别

java hashmap覆盖值

java - 如何从g1gc日志计算对象升级率?

c# - 在 MSBuild 配置文件中指定记录器

javascript - 我如何使用 sentry/raven-js 记录所有内容

java -postgresql 最后插入的 id 插入时未获取