Maven插件记录器兼容性 [英] Maven Plugin Logger Compatibility
问题描述
我正在编写一个Maven插件(Mojo),用于导入其他项目使用的Jar库。该库中至少有一个类使用Apache Log4j进行日志记录,但Maven为Mojo提供的记录器无法正确配置Log4j。
I am writing a Maven plugin (Mojo) that imports a Jar library used by other projects. At least one of the classes in that library use Apache Log4j for logging, but Log4j is not going to be properly configured by the logger that Maven provides to the Mojo.
是有没有简单的方法来弥合这些?不幸的是, org.apache.log4j.Logger
和 org.apache.maven.logging.Log
不共享共同点超级接口或超类,所以我不能简单地使用 setLog()
类型函数。欢迎大家提出意见;目前我打算要么忽略它,要么写一个可以使用它的桥接类。
Is there any simple way to bridge between these? Unfortunately, org.apache.log4j.Logger
and org.apache.maven.logging.Log
do not share a common superinterface or superclass, so I can't simply have a setLog()
type function. Any suggestions would be welcome; currently I am planning to either just ignore it, or write a bridge class that can use either.
推荐答案
如果你想写桥梁类,请看SLF4J来源: http://www.slf4j.org/ legacy.html#log4j-over-slf4j
他们在log4j桥中做了类似的事情。
If you want to write a bridge class, look at SLF4J sources: http://www.slf4j.org/legacy.html#log4j-over-slf4j They are doing something quite similar in their log4j bridge.
这篇关于Maven插件记录器兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!