2

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.

JSBach
  • 4,679
  • 8
  • 51
  • 98

3 Answers3

1

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.

Tavisco
  • 11
  • 2
  • This is an excerpt from the answer in the question I linked and comes from a Quarkus dev: "The property that controls the root logging level is quarkus.log.level (and defaults to INFO). This property can be set either in application.properties or can be overridden at runtime using -Dquarkus.log.level=DEBUG. " This leads me to believe this is possible. – JSBach Feb 25 '20 at 12:57
0

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

JSBach
  • 4,679
  • 8
  • 51
  • 98
0

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.

Julio Faerman
  • 13,228
  • 9
  • 57
  • 75