如果我正在创建一个新的 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/