Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Quarkus Logging Category Level via Environment Variables

In Spring, it is possible to set the Logging Category Level via environment variables. I've tried the same in a Quarkus application with the following logger declaration:

package org.my.group.resteasyjackson;

public class JacksonResource {

  private static final Logger LOGGER = LoggerFactory.getLogger(JacksonResource.class);
  
  @GET
  public Set<Quark> list() {
    LOGGER.info("Hello");
    return quarks;
  }
}

Executing the build artifact with

QUARKUS_LOG_CATEGORY_ORG_MY_LEVEL=WARN java -jar my-artifactId-my-version-runner.jar

will log anything at info level (since it is the default), therefore the "Hello" message.

However, inserting

quarkus.log.category."org.my".level=WARN

in the application.properties file works as desired. Are environment variables in this use case not usable for Quarkus applications?

like image 538
Sincostan Avatar asked Dec 30 '20 07:12

Sincostan


People also ask

What is the default log format in Quarkus?

By default, Quarkus uses a pattern-based logging formatter that generates human-readable text logs. You can configure the format for each log handler via a dedicated property. For the console handler, the property is quarkus.log.console.format. The logging format string supports the following symbols:

How do I create a staging environment in Quarkus?

This is quite easy to do as Quarkus will simply use the quarkus-profile system property or the QUARKUS_PROFILE environment variable. Let’s say with have a staging environment and want to set some specific values for this environment. It’s just a matter of adding these variables with the prefix %staging in the application.properties:

What are logging levels in Quarkus?

You can use logging levels to categorize logs by severity or by their impact on the health and stability of your Quarkus application. Logging levels let you filter the critical events from the events that are purely informative. Table 3.3.

How to set the logging level for a class?

If you need to configure logging for a class, you can use the SPRING_APPLICATION_JSON variable." I also tried to set logging level via environment variable but as already mentioned it is not possible by using environment variable with upper case name, eg. LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=DEBUG.


Video Answer


1 Answers

Just tried with quarkus 1.13.1 and adding extra underscores for the quotes seems to work, try:

QUARKUS_LOG_CATEGORY__ORG_MY__LEVEL=WARN

like image 87
Steven Hawkins Avatar answered Sep 27 '22 16:09

Steven Hawkins