问题描述
我正在使用 jose4j 在我正在工作的Java应用程序中.这是一个JSON Web令牌库,我发现将软件包名称放入我的Log4j配置文件中无助于我从此内容中看到的(许多)调试日志记录消息.这是我相关的log4j配置部分
<Root level="debug"> <AppenderRef ref="Console"></AppenderRef> </Root> <Logger name="org.jose4j" level="warn" additivity="false"> <AppenderRef ref="Console"></AppenderRef> </Logger>
所以,我本质上只想在Jose4j上升到警告水平(或更可怕)时从Jose4j中看到日志消息.
我能够收集的几件事.
-
将root Logger设置为"信息"确实使Jose4J调试消息消失了,因此Jose4J的Logger至少知道我的记录设置.
It looks like the logger that jose4j uses is org.sl4j
-
我有一个类似的问题昨天.似乎添加了一些罐子可以解决这个问题,但我对此没有运气.
我还添加了这个jar classpath ...这也没有起作用.
有人知道我如何让这个库与我的记录设置一起工作?
推荐答案
两个点:
- 您只需要具有一个 SLF4J接口的实现.只需打开org.slf4j.spi.loggerfactorybinder并检查类型层次结构(ctrl-t in eclipse中).
- 对于log4j,必须是/artifact/org.slf4j/slf4j-log4j12/1.7.25 ,例如.
问题描述
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?
推荐答案
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.