【问题标题】:Change log level in Vert.x by adding a configuration file通过添加配置文件更改 Vert.x 中的日志级别
【发布时间】:2017-02-16 15:21:10
【问题描述】:

我想在我的 Vert.x 应用程序中更改默认日志级别,所以我在项目中添加了一个名为 vertx-default-jul-logging.properties 的配置文件,然后添加其根文件夹作为类路径中的源文件夹,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

现在...这些都不起作用,日志级别没有改变一点;我看不到任何调试痕迹。

我做错了什么?

【问题讨论】:

  • 您是否将此文件放入您的src/main/resources 中?试过了,效果很好。
  • 我遇到了同样的问题。使用ch.qos.logback 包并在 src/main/resources/ 中拥有类似的配置文件,只需不断从 io.netty 获取 DEBUG 日志记录

标签: java logging vert.x


【解决方案1】:

您需要像 Marouane 状态一样将 vertx-default-jul-logging.properties 文件添加到 /src/main/resources 文件夹中。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-14
    • 1970-01-01
    • 1970-01-01
    • 2017-12-07
    • 2019-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多