有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Vert中的java更改日志级别。通过添加一个配置文件

我想更改Vert中的默认日志级别。我已经添加了一个名为vertxdefaultjul-logging的配置文件。属性添加到项目中,然后将其根文件夹作为源文件夹添加到类路径just like the documentation says

该文件包含以下内容:

handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler
java.util.logging.SimpleFormatter.format=%5$s %6$s\n
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level=FINEST
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.formatter=io.vertx.core.logging.impl.VertxLoggerFormatter

# Put the log in the system temporary directory
java.util.logging.FileHandler.pattern=%t/vertx.log

.level=FINEST
io.vertx.ext.web.level=FINEST
io.vertx.level=FINEST
com.hazelcast.level=FINEST
io.netty.util.internal.PlatformDependent.level=FINEST

现在。。。这一切都不起作用,日志级别没有任何变化;我看不到任何调试跟踪

我做错了什么


共 (1) 个答案

  1. # 1 楼答案

    您需要添加vertx默认的七月日志记录。属性文件保存到/src/main/resources文件夹中,如Marouane所述

    如果您需要以编程方式更改日志文件的位置,例如,您可以这样做:

    String logFile = "/var/log/my-app.log";
    System.setProperty("java.util.logging.FileHandler.pattern", logFile);