A simple logging setup using SLF4J's slf4j-simple
logging implementation.
Follow these instructions to build and run the example program:
- Pre-requisite: Java 21
- Build the program distribution
-
./gradlew installDist
-
- Run the program
-
build/install/slf4j-simple/bin/slf4j-simple
- It will output something like the following.
-
19:27:10 [main] WARN dgroomes.slf4j_simple.Main - A WARN-level message 19:27:10 [main] ERROR dgroomes.slf4j_simple.Main - An ERROR-level message
- Notice how the code specified TRACE, DEBUG and INFO level messages but only WARN and ERROR messages were logged.
Study the logging configuration file
src/main/resources/simplelogger.properties
to see why.
-
How do you debug SLF4J itself? There must be a way to turn on debug or trace logs withing SLF4J's initialization phase...