Skip to content

Commit

Permalink
Cover quarkus.log.min-level scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo gonzalez granados committed Sep 15, 2021
1 parent 564d327 commit fe1d4d6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.ts.logging.jboss;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
Expand Down Expand Up @@ -42,7 +43,17 @@ public void addLogMessageInFieldWithCustomCategoryLogger(@PathParam("level") Str
addLogMessage(customCategoryLog, level, message);
}

@GET
public void logExample() {
LOG.fatal("Fatal log example");
LOG.error("Error log example");
LOG.warn("Warn log example");
LOG.info("Info log example");
LOG.debug("Debug log example");
LOG.trace("Trace log example");
}

private void addLogMessage(Logger logger, String level, String message) {
logger.log(Logger.Level.valueOf(level), message);
}
}
}
9 changes: 9 additions & 0 deletions logging/jboss/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#When you set the logging level below the minimum logging level, you must adjust the minimum logging level as well.
#Otherwise, the value of minimum logging level overrides the logging level.
# DOC:
# https://access.redhat.com/documentation/en-us/red_hat_build_of_quarkus/1.11/html-single/configuring_logging_with_quarkus/index#ref-example-logging-configuration_quarkus-configuring-logging
# https://quarkus.io/guides/logging
# https://quarkus.io/guides/all-config#quarkus-core_quarkus.log.min-level

#quarkus.log.min-level=DEBUG
quarkus.log.level=TRACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.jboss.logging.Logger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.RestService;
Expand Down Expand Up @@ -71,6 +72,23 @@ public void shouldCategoryBeWorkingOnlyForAffectedLoggers() {
app.logs().assertContains(MESSAGE + "category2");
}

@Test
// TODO
// https://github.com/quarkusio/quarkus/issues/20066
@Disabled
public void checkDefaultLogMinLevel() {
app.given().when().get("/log").then().statusCode(204);

app.logs().assertContains("Fatal log example");
app.logs().assertContains("Error log example");
app.logs().assertContains("Warn log example");
app.logs().assertContains("Info log example");
app.logs().assertContains("Debug log example");

// the value of minimum logging level overrides the logging level
app.logs().assertDoesNotContain("Trace log example");
}

private void verifyLoggingRules(BiConsumer<Logger.Level, String> writer) {
// Added INFO log
writer.accept(Logger.Level.INFO, MESSAGE + "1");
Expand Down

0 comments on commit fe1d4d6

Please sign in to comment.