How do I disable jose4j log messages through my log4j config?

百般思念 提交于 2019-12-12 05:37:53

问题


I am using jose4j in a java application that I am working on. It is a json web token library, and I've found that putting the package name inside my log4j config file does nothing to quiet the (many) debug logging messages that I am seeing from this thing. Here's my relevant log4j config section

<Root level="debug">
    <AppenderRef ref="Console"></AppenderRef>
</Root>
<Logger name="org.jose4j" level="warn" additivity="false">
    <AppenderRef ref="Console"></AppenderRef>
</Logger>

So, I essentially only want to see log messages from jose4j when they rise to the level of warn (or more dire).

A few things I have been able to gather.

  • Setting the root logger to "info" does make the jose4j debug messages go away, so jose4j's logger at least knows about my logging setup.

  • It looks like the logger that jose4j uses is org.sl4j

  • I had a similar issue yesterday. It seemed like adding a few jars did the trick to fix that issue, but I'm not having luck with this.

I also added this jar to the classpath... this also did not work.

Does anyone know how I can get this library to work with my logging setup?


回答1:


Two points:

  • You need to have only one implementation of the slf4j interface. Just open the org.slf4j.spi.LoggerFactoryBinder and check the Type hierarchy (Ctrl-T in Eclipse).
  • For log4j it has to be https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12/1.7.25, for example.


来源:https://stackoverflow.com/questions/44677501/how-do-i-disable-jose4j-log-messages-through-my-log4j-config

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