gpt4 book ai didi

java - 如何禁用 Javalin 日志记录

转载 作者:行者123 更新时间:2023-11-30 01:46:03 33 4
gpt4 key购买 nike

我想在 Javalin 下关闭此日志记录:

[main] INFO org.eclipse.jetty.util.log - Logging initialized @850ms to org.eclipse.jetty.util.log.Slf4jLog
[main] INFO io.javalin.Javalin - Starting Javalin ...
[main] INFO io.javalin.Javalin - Listening on http://localhost:8003/
[main] INFO io.javalin.Javalin - Javalin started in 334ms \o/
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[main] INFO io.javalin.Javalin - Starting Javalin ...
[main] INFO io.javalin.Javalin - Listening on http://localhost:6667/
[main] INFO io.javalin.Javalin - Javalin started in 7ms \o/
[main] INFO io.javalin.Javalin - Stopping Javalin ...
[main] INFO io.javalin.Javalin - Javalin has stopped
[main] INFO io.javalin.Javalin - Stopping Javalin ...
[main] INFO io.javalin.Javalin - Javalin has stopped

...但是Javalin似乎没有办法关闭这些日志。有办法吗?谢谢

最佳答案

Javalin 使用 SLF4J用于日志记录(您甚至可以在第一条消息中看到类名Slf4jLog)。这是一个抽象,可以与许多不同的实际实现一起使用,因此第一步是找到您的项目使用哪个。列出依赖项( GradleMaven )并查找 slf4j-<something> (slf4j-api 除外)或 logback-classic 。然后看https://www.slf4j.org/manual.html#swapping对于您找到的并找到如何将其配置为设置为高于 INFO 的级别.

例如如果您关注了

Javalin does not have a logger included, which means that you have to add your own logger. If you don’t know/care a lot about Java loggers, the easiest way to fix this is to add the following dependency to your project:

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
</dependency>

来自 Javalin 文档,请参阅 How to configure slf4j-simple .

关于java - 如何禁用 Javalin 日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57959261/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com