LOGGING BASICS
Logging frameworks:
- SLF4J - Specification / Abstraction that decouples business code from logging API
- Logback - Implementation of the above
- JUL - Same, another framework
Logging levels:
If in our application we set logging level as INFO, then all below levels will also be activated:
... Meaning that log.debug won't print anything when app runs:
But log.info, log.warn, log.error instances will be printed in console.
LOGGING WITH SPRING BOOT
Spring Boot provides both SLF4J and Logback out-of-the-box:
To set logging level for our Spring app, in application properties:
To set logging level for our Spring app, in application properties:
Package org.hibernate will only print WARN and ERROR levels. We don't need to know every little detail.
Same for JdbcTemplate.
If issues arise, we can DEBUG or TRACE these.
For advanced configuration, logback-spring.xml:
Same for JdbcTemplate.
If issues arise, we can DEBUG or TRACE these.
For advanced configuration, logback-spring.xml:
- Appender tag: We define a ConsoleAppender, meaning streamed logs will show on console.
- Encoder-pattern tag: We can format the text with various configurations
- Root tag: Finally we set our created Appender to root level
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
What may be missing, or could get better?