private static final Logger myLogger = LoggerFactory.getLogger("NAME");
I have a couple of loggers created like the example above, the thing is, when I run my Spring app with --debug
, myLogger.debug("something")
isn't logged, only spring default/internal loggers acctually make use of the --debug
args.
How can I make my loggers also use --<level>
args?
This is by design. It is not possible to make the other loggers use —debug or any other level.
From the docs,
The default log configuration echoes messages to the console as they are written. By default, ERROR-level, WARN-level, and INFO-level messages are logged. You can also enable a “debug” mode by starting your application with a --debug flag.
$ java -jar myapp.jar --debug
[Note] You can also specify debug=true in your application.properties.
When the debug mode is enabled, a selection of core loggers (embedded container, Hibernate, and Spring Boot) are configured to output more information. Enabling the debug mode does not configure your application to log all messages with DEBUG level.
Alternatively, you can enable a “trace” mode by starting your application with a --trace flag (or trace=true in your application.properties). Doing so enables trace logging for a selection of core loggers (embedded container, Hibernate schema generation, and the whole Spring portfolio).
However you can use below key value to log all debug messages in application properties file
logging.level.root=debug
More on the implementation here https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With