简体   繁体   English

Spring Boot日志记录/ Java日志记录-显示配置/设置的工具

[英]Spring boot logging / Java logging - Tool to show config/setup

I'm used to using log4j and whenever there were setup/config problems I'd enable "-Dlog4j.debug" and all the config info would be dumped out at startup. 我习惯于使用log4j,每当出现设置/配置问题时,我都会启用“ -Dlog4j.debug”,并且所有配置信息都将在启动时转储。
This was very useful on a number of occasions. 这在许多场合下非常有用。

Now I'm working on a Spring boot application, which I've found uses: 现在,我正在开发一个Spring Boot应用程序,该应用程序已被使用:

  1. Commons logging Logger statements in the client code 客户端代码中的Commons Logging Logger语句
  2. A bridge jar (jcl-over-slf4j-xxx.jar) which translates the commons logging calls into slf4j more info here 桥罐子(JCL-过SLF4J-xxx.jar),其转换的通用日志调用到SLF4J 更多的信息在这里
  3. Finally slf4j uses "logback" as the underlying logging framework 最后,slf4j使用“ logback”作为基础的日志框架

I found it rather painful to figure all this out. 我发现弄清楚所有这些都非常痛苦。
Is there an equivalent of -Dlog4j.debug which can show me how this is all hanging together at startup time? 是否有等效的-Dlog4j.debug可以向我展示在启动时如何将它们挂在一起?

This is the best/only option I've found so far, and it's logback specific. 这是到目前为止我发现的最好/唯一的选项,它是特定于Logback的。
Use this -D on the command line: 在命令行上使用此-D:

-Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener

Taken from here 这里取
This essentially is the logback equivalent of log4j's -Dlog4j.debug. 从本质上讲,这等效于log4j的-Dlog4j.debug。
It dumps the logback startup sequence to the console at startup time, as the logging system is initialised. 在初始化日志系统时,它将在启动时将logback启动序列转储到控制台。

This is not a true answer as I'd like some messages to show before this to show why logback is being used, but I haven't found anything like that yet. 这不是一个正确的答案,因为我希望在此之前显示一些消息来说明为什么使用logback,但是我还没有找到类似的东西。

Aside: This may also be useful for Spring Boot: 另外:这对于Spring Boot也可能有用:

-Ddebug

Taken from here and here 这里这里

If you are using logback, I assume you are using the logback.xml file? 如果您使用的是logback,我假设您使用的是logback.xml文件? Then if you start that file with <configuration debug="true"> then it should dump the status information. 然后,如果您使用<configuration debug="true">启动该文件,则它应该转储状态信息。 More information in the documentation under status data section. 状态数据部分下的文档中的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM