简体   繁体   中英

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.
This was very useful on a number of occasions.

Now I'm working on a Spring boot application, which I've found uses:

  1. Commons logging Logger statements in the client code
  2. A bridge jar (jcl-over-slf4j-xxx.jar) which translates the commons logging calls into slf4j more info here
  3. Finally slf4j uses "logback" as the underlying logging framework

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?

This is the best/only option I've found so far, and it's logback specific.
Use this -D on the command line:

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

Taken from here
This essentially is the logback equivalent of log4j's -Dlog4j.debug.
It dumps the logback startup sequence to the console at startup time, as the logging system is initialised.

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.

Aside: This may also be useful for Spring Boot:

-Ddebug

Taken from here and here

If you are using logback, I assume you are using the logback.xml file? Then if you start that file with <configuration debug="true"> then it should dump the status information. More information in the documentation under status data section.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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