I am looking for a way to change the log level of one or multiple classes/packages of a Quarkus app (JVM) during runtime. Is there an API I can use to programmatically change the levels, e.g. by exposing a REST API or does there already exist some other solution?
I am aware of https://quarkus.io/guides/logging but this only discusses changing the log levels statically via a JVM property or applications.properties.
In terms of scaling, the challenge is to change log levels in each instance. So to avoid all pitfalls following is needed: Dynamically change the log level at runtime without application restart. Propagation of log level changes across the application instances.
To change log levels as a root user, perform the following: To enable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=DEBUG) To disable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=INFO)
Setting Levels using Configuration File log4j provides you configuration file based level setting which sets you free from changing the source code when you want to change the debugging level. Following is an example configuration file which would perform the same task as we did using the log. setLevel(Level.
For future readers: I created a Quarkus extension that can be seen here: https://github.com/quarkiverse/quarkiverse-logging-ui
And can be used by adding this dependency
<dependency>
<groupId>io.quarkiverse.loggingui</groupId>
<artifactId>quarkus-logging-ui</artifactId>
<version>0.0.2</version>
</dependency>
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