From 9bdc045fe62d185aad278dd79fb93091f9fb5b40 Mon Sep 17 00:00:00 2001 From: pablo gonzalez granados Date: Fri, 10 Sep 2021 18:08:55 +0200 Subject: [PATCH] Cover quarkus.log.min-level scenario --- .../io/quarkus/ts/core/LoggerResource.java | 25 ++++++++++++++++ .../src/main/resources/application.properties | 11 +++++-- .../ts/core/LoggerDefaultPropertiesIT.java | 30 +++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 javaee-like-getting-started/src/main/java/io/quarkus/ts/core/LoggerResource.java create mode 100644 javaee-like-getting-started/src/test/java/io/quarkus/ts/core/LoggerDefaultPropertiesIT.java diff --git a/javaee-like-getting-started/src/main/java/io/quarkus/ts/core/LoggerResource.java b/javaee-like-getting-started/src/main/java/io/quarkus/ts/core/LoggerResource.java new file mode 100644 index 0000000000..9f3f08c97c --- /dev/null +++ b/javaee-like-getting-started/src/main/java/io/quarkus/ts/core/LoggerResource.java @@ -0,0 +1,25 @@ +package io.quarkus.ts.core; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jboss.logging.Logger; + +@Path("/log") +public class LoggerResource { + + private static final Logger LOG = Logger.getLogger(LoggerResource.class); + + @GET + @Produces(MediaType.TEXT_PLAIN) + 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"); + } +} diff --git a/javaee-like-getting-started/src/main/resources/application.properties b/javaee-like-getting-started/src/main/resources/application.properties index 3c1ac56a1a..47de8cf85b 100644 --- a/javaee-like-getting-started/src/main/resources/application.properties +++ b/javaee-like-getting-started/src/main/resources/application.properties @@ -1,2 +1,9 @@ -# Configuration file -# key = value \ No newline at end of file +#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=FATAL +#quarkus.log.level=DEBUG diff --git a/javaee-like-getting-started/src/test/java/io/quarkus/ts/core/LoggerDefaultPropertiesIT.java b/javaee-like-getting-started/src/test/java/io/quarkus/ts/core/LoggerDefaultPropertiesIT.java new file mode 100644 index 0000000000..9fd7ec2eff --- /dev/null +++ b/javaee-like-getting-started/src/test/java/io/quarkus/ts/core/LoggerDefaultPropertiesIT.java @@ -0,0 +1,30 @@ +package io.quarkus.ts.core; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.QuarkusApplication; + +@QuarkusScenario +public class LoggerDefaultPropertiesIT { + + @QuarkusApplication + static final RestService app = new RestService(); + + @Test + // TODO https://github.com/quarkusio/quarkus/pull/13376 + @Disabled + public void checkDefaultLogMinLevelIsDebug() { + 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"); + + app.logs().assertDoesNotContain("Trace log example"); + } +}