SLFJ4 bridge for the Maven logger

余生长醉 提交于 2021-02-08 05:36:38

问题


I'm writing a Maven 3.x plugin and want to log with SLF4J & Logback.

I found some SLF4J bindings for the Maven Logger:

  • http://www.jcabi.com/jcabi-maven-slf4j/index.html
  • https://bitbucket.org/peachjean/slf4j-mojo

However, these seem to be SLF4J bindings but I believe what I need is a bridge for the Maven Logger i.e. to bridge/route all Maven log statements to SLF4J and use LogBack binding with logback.xml config.


回答1:


You can use SLF4J directly from Maven plugin since Maven 3.1:

The standard Maven distribution, from Maven 3.1.0 onward, uses the SLF4J API for logging combined with the SLF4J Simple implementation. Future versions may use a more advanced implementation, but we chose to start simple.

No bridges, bindings, etc. needed.

Source: https://maven.apache.org/maven-logging.html




回答2:


Your plugin should log through Log class. Logback is not required. Just forward all your logs to SLF4J and add jcabi-maven-slf4j dependency to the plugin. That's it.



来源:https://stackoverflow.com/questions/22271518/slfj4-bridge-for-the-maven-logger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!