In the previous article, I introduced Quarkus – A framework described as Supersonic Subatomic that helps run compatible containers in cloud environments. Quarkus can be said as an alternative solution to help bring Java closer to cloud environments.
In this article we will learn more about Quarkus, namely the simple way of logging logging in quarkus similar to the famous Spring-Framework config that may have been familiar to you.
1. Profile turn
To configure logging in Quarkus, you will use the same application.properties file as Spring
This file is located by default at src/main/resources/application.properties
2. The logging API is supported by Quarkus
You can use any of the logging APIs of any of the following APIs, supported by Quarkus: v
- JDK java.util.logging
- JBoss Logging
- SLF4J
- Apache Commons Logging
3. Learn some config through examples
Console DEBUG Logging, no color config for log, Shortened Time, Shortened Category Prefixes
1 2 3 4 5 6 7 | quarkus.log.console.enable=true quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n quarkus.log.console.level=DEBUG quarkus.log.console.color=false quarkus.log.category."io.quarkus".level=DEBUG |
If the project requires logging to the file, you can configure it like this:
1 2 3 4 5 6 7 8 9 | quarkus.log.file.enable=true # Bắn log vào file trace.log đặt tại thư mục /ghi-log quarkus.log.file.path=/ghi-log/trace.log quarkus.log.file.level=TRACE quarkus.log.file.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n # Đặt log level cho các package (io.quarkus.smallrye.jwt, io.undertow.request.security) là TRACE quarkus.log.category."io.quarkus.smallrye.jwt".level=TRACE quarkus.log.category."io.undertow.request.security".level=TRACE |
4. Conclusion
Above is some information I summarized from the docs https://quarkus.io/guides/logging the owner of quarkus. Docs are always full of things, detailing ostrich types, but how much to use
The configs in the example section 3 are the ones I use and use in projects, what have you used? Package yet? Let’s find out and share