JSBach
JSBach

Reputation: 4747

How to configure Quarkus log level?

I want to change the log level of my quarkus app, and everywhere where I could find any reference, it pointed me to the application.properties file.

This is my application.properties content:

quarkus.log.level=TRACE
quarkus.log.console.enable=true
quarkus.log.console.level=TRACE

"%test".quarkus.log.level=TRACE
"%test".quarkus.log.console.enable=true
"%test".quarkus.log.console.level=TRACE

And this is my code:

Logger LOGGER = LoggerFactory.getLogger(AccessorController.class);

 LOGGER.trace("TRACE");
 LOGGER.debug("DEBUG");
 LOGGER.info("INFO");
 LOGGER.error("ERROR");

But this is the output:

Feb 24, 2020 1:42:35 PM com.MyClass greetings
INFO: INFO
Feb 24, 2020 1:42:35 PM com.MyClass greetings
ERROR: ERROR

Do I need any extra extension to get it working?

I have read this question but it didn't work for me. I really have no idea, I created a simple app from the Quarkus bootstrap and I still have the same behavior.

Upvotes: 2

Views: 7836

Answers (3)

Julio Faerman
Julio Faerman

Reputation: 13501

It's not posible to change the logging level at runtime, as far as i could test. As a workaround, i recommend setting the log level in the Main method before delegating to quarkus. Something like:

System.setProperty("quarkus.log.console.level", "DEBUG");
Quarkus.run(YourApp.class);

Same goes for config file locations and other system properties.

Upvotes: 0

JSBach
JSBach

Reputation: 4747

I just found out what was going on. It seems that the yaml-config dependency does not recognize as a valid entry

quarkus.log.level:  WARN

but

quarkus:
  log:
    level:  WARN

works perfectly

Upvotes: 0

Tavisco
Tavisco

Reputation: 11

You can't use SLF4J's log levels on the properties file as far as I know. You need to use any of the values from java.utils.logging.Level.

And as the Javadoc says, those are:

SEVERE (highest value)
WARNING
INFO
CONFIG
FINE
FINER
FINEST (lowest value) 

I've replaced my config to quarkus.log.category."com.my.package".level=FINEST and log.trace("MSG"); from SLF4J worked as intended.

Upvotes: 1

Related Questions