我试图从MongoDB中隐藏Level.INFO日志,因为它占用了我控制台中太多的空间(实际上它占用了我大约50行cmd)。
这是代码,我尝试:
Logger logger = Logger.getLogger("org.mongodb.driver");
logger.setLevel(Level.OFF);
和我的pom.xml依赖项:
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.8.1</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.6</version>
</dependency>
</dependencies>
1条答案
按热度按时间ivqmmu1c1#
所以,你需要这个:
以下是所需的导入:
下面是一行代码:
它将所有日志设置为仅错误。