本文介绍了如何通过我的log4j配置禁用jose4j日志消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的Java应用程序中使用 jose4j .这是一个json网络令牌库,我发现将包名放在我的log4j配置文件中并没有使我从此东西中看到的(许多)调试日志消息安静下来.这是我相关的log4j配置部分

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>

因此,我基本上只希望看到jose4j的日志消息上升到警告级别(或更严重).

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.

  • 将根记录器设置为"info"确实会使jose4j调试消息消失,因此jose4j的记录器至少知道我的记录设置.

  • 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.

看来jose4j使用的记录器是 org.sl4j

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.

我还向其中添加了此罐子 classpath ...这也不起作用.

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?

推荐答案

两点:

  • 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.

这篇关于如何通过我的log4j配置禁用jose4j日志消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 00:53