Possibility to separately specify log levels for log handlers - basic (#32779)

* Possibility to separately specify log levels for log handlers

Closes #32619

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
Co-authored-by: Václav Muzikář <vaclav@muzikari.cz>

* Edit properties description

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

---------

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
Co-authored-by: Václav Muzikář <vaclav@muzikari.cz>
This commit is contained in:
Martin Bartoš 2024-09-13 11:05:03 +01:00 committed by GitHub
parent bfe9d2343c
commit 45ef84a397
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 432 additions and 70 deletions

View file

@ -158,6 +158,13 @@ GELF support has been deprecated for a while now, and with this release it has b
Other log handlers are available and fully supported to be used as a replacement of GELF, for example Syslog. For details
see the https://www.keycloak.org/server/logging[Logging guide].
= Specify different log levels for log handlers
It is possible to specify log levels for all available log handlers, such as `console`, `file`, or `syslog`.
The more fine-grained approach provides the ability to control logging over the whole application and be tailored to your needs.
For more information, see the https://www.keycloak.org/server/logging[Logging guide].
= All user sessions are persisted by default
{project_name} 25 introduced the feature `persistent-user-sessions`. With this feature enabled all user sessions are persisted in the database as opposed to the previous behavior where only offline sessions were persisted.

View file

@ -9,15 +9,18 @@ title="Configuring logging"
summary="Learn how to configure Logging"
includedOptions="log log-*">
{project_name} uses the JBoss Logging framework. The following is a high-level overview for the available log handlers:
{project_name} uses the JBoss Logging framework.
The following is a high-level overview for the available log handlers with the common parent log handler `root`:
* root
** console (_default_)
** file
** Syslog
<@opts.expectedValues option="log"/>
== Logging configuration
Logging is done on a per-category basis in {project_name}. You can configure logging for the root log level or for more specific categories such as `org.hibernate` or `org.keycloak`. This {section} describes how to configure logging.
Logging is done on a per-category basis in {project_name}.
You can configure logging for the root log level or for more specific categories such as `org.hibernate` or `org.keycloak`.
It is also possible to tailor log levels for each particular log handler.
This {section} describes how to configure logging.
=== Log levels
@ -71,15 +74,59 @@ To enable log handlers, enter the following command:
<@kc.start parameters="--log=\"<handler1>,<handler2>\""/>
The available handlers are
<@profile.ifCommunity>
`console`, `file`, `syslog`.
</@profile.ifCommunity>
<@profile.ifProduct>
`console`, `file` and `syslog`.
</@profile.ifProduct>
The available handlers are:
<@opts.expectedValues option="log"/>
The more specific handler configuration mentioned below will only take effect when the handler is added to this comma-separated list.
== Specify log level for each handler
The `log-level` property specifies the global root log level and levels for selected categories.
However, a more fine-grained approach for log levels is necessary to comply with the modern application requirements.
To set log levels for particular handlers, properties in format `log-<handler>-level` (where `<handler>` is available log handler) were introduced.
It means properties for log level settings look like this:
* `log-console-level` - Console log handler
* `log-file-level` - File log handler
* `log-syslog-level` - Syslog log handler
NOTE: The `log-<handler>-level` properties are available only when the particular log handlers are enabled.
More information in log handlers settings below.
Only log levels specified in <<Log levels>> section are accepted, and *must be in lowercase*.
There is no support for specifying particular categories for log handlers yet.
=== General principle
It is necessary to understand that setting the log levels for each particular handler *does not override the root level* specified in the `log-level` property.
Log handlers respect the root log level, which represents the maximal verbosity for the whole logging system.
It means individual log handlers can be configured to be less verbose than the root logger, but not more.
Specifically, when an arbitrary log level is defined for the handler, it does not mean the log records with the log level will be present in the output.
In that case, the root `log-level` must also be assessed.
Log handler levels provide the *restriction for the root log level*, and the default log level for log handlers is `all` - without any restriction.
=== Examples
.Example: `debug` for file handler, but `info` for console handler:
<@kc.start parameters="--log=console,file --log-level=debug --log-console-level=info"/>
The root log level is set to `debug`, so every log handler inherits the value - so does the file log handler.
To hide `debug` records in the console, we need to set the minimal (least severe) level to `info` for the console handler.
.Example: `warn` for all handlers, but `debug` for file handler:
<@kc.start parameters="--log=console,file,syslog --log-level=debug --log-console-level=warn --log-syslog-level=warn"/>
The root level must be set to the most verbose required level (`debug` in this case), and other log handlers must be amended accordingly.
.Example: `info` for all handlers, but `debug`+`org.keycloak.events:trace` for Syslog handler:
<@kc.start parameters="--log=console,file,syslog --log-level=debug,org.keycloak.events:trace, --log-syslog-level=trace --log-console-level=info --log-file-level=info"/>
In order to see the `org.keycloak.events:trace`, the `trace` level must be set for the Syslog handler.
== Console log handler
The console log handler is enabled by default, providing unstructured log messages for the console.
@ -158,6 +205,13 @@ Colored console log output for unstructured logs is disabled by default. Colors
<@kc.start parameters="--log-console-color=<false|true>"/>
=== Configuring the console log level
Log level for console log handler can be specified by `--log-console-level` property as follows:
<@kc.start parameters="--log-console-level=warn"/>
For more information, see the section <<Specify log level for each handler>> above.
== File logging
As an alternative to logging to the console, you can use unstructured logging to a file.
@ -187,6 +241,13 @@ To configure a different logging format for the file log handler, enter the foll
See <<Configuring the console log format>> for more information and a table of the available pattern configuration.
=== Configuring the file log level
Log level for file log handler can be specified by `--log-file-level` property as follows:
<@kc.start parameters="--log-file-level=warn"/>
For more information, see the section <<Specify log level for each handler>> above.
== Centralized logging using Syslog
{project_name} provides the ability to send logs to a remote Syslog server.
@ -213,6 +274,13 @@ To configure the endpoint(_host:port_) of your centralized logging system, enter
When the Syslog handler is enabled, the host is using `localhost` as host value.
The Default port is `514`.
=== Configuring the Syslog log level
Log level for Syslog log handler can be specified by `--log-syslog-level` property as follows:
<@kc.start parameters="--log-syslog-level=warn"/>
For more information, see the section <<Specify log level for each handler>> above.
=== Configuring the Syslog protocol
Syslog uses TCP as the default protocol for communication.
To use UDP instead of TCP, add the `--log-syslog-protocol` option as follows:

View file

@ -77,6 +77,14 @@ public class LoggingOptions {
.description("Set the log output to JSON or default (plain) unstructured logging.")
.build();
public static final Option<Level> LOG_CONSOLE_LEVEL = new OptionBuilder<>("log-console-level", Level.class)
.category(OptionCategory.LOGGING)
.defaultValue(Level.ALL)
.description("Set the log level for the console handler. It specifies the most verbose log level for logs shown in the output. "
+ "It respects levels specified in the 'log-level' option, which represents the maximal verbosity for the whole logging system. "
+ "For more information, check the Logging guide.")
.build();
public static final Option<String> LOG_CONSOLE_FORMAT = new OptionBuilder<>("log-console-format", String.class)
.category(OptionCategory.LOGGING)
.description("The format of unstructured console log entries. If the format has spaces in it, escape the value using \"<format>\".")
@ -112,6 +120,14 @@ public class LoggingOptions {
.defaultValue(new File(DEFAULT_LOG_PATH))
.build();
public static final Option<Level> LOG_FILE_LEVEL = new OptionBuilder<>("log-file-level", Level.class)
.category(OptionCategory.LOGGING)
.defaultValue(Level.ALL)
.description("Set the log level for the file handler. It specifies the most verbose log level for logs shown in the output. "
+ "It respects levels specified in the 'log-level' option, which represents the maximal verbosity for the whole logging system. "
+ "For more information, check the Logging guide.")
.build();
public static final Option<String> LOG_FILE_FORMAT = new OptionBuilder<>("log-file-format", String.class)
.category(OptionCategory.LOGGING)
.description("Set a format specific to file log entries.")
@ -142,6 +158,14 @@ public class LoggingOptions {
.defaultValue("localhost:514")
.build();
public static final Option<Level> LOG_SYSLOG_LEVEL = new OptionBuilder<>("log-syslog-level", Level.class)
.category(OptionCategory.LOGGING)
.defaultValue(Level.ALL)
.description("Set the log level for the Syslog handler. It specifies the most verbose log level for logs shown in the output. "
+ "It respects levels specified in the 'log-level' option, which represents the maximal verbosity for the whole logging system. "
+ "For more information, check the Logging guide.")
.build();
public static final Option<String> LOG_SYSLOG_TYPE = new OptionBuilder<>("log-syslog-type", String.class)
.category(OptionCategory.LOGGING)
.expectedValues(Arrays.stream(SyslogHandler.SyslogType.values()).map(f -> f.toString().toLowerCase()).toList())

View file

@ -42,6 +42,11 @@ public final class LoggingPropertyMappers {
.paramLabel("output")
.transformer(LoggingPropertyMappers::resolveLogOutput)
.build(),
fromOption(LoggingOptions.LOG_CONSOLE_LEVEL)
.isEnabled(LoggingPropertyMappers::isConsoleEnabled, CONSOLE_ENABLED_MSG)
.to("quarkus.log.console.level")
.paramLabel("level")
.build(),
fromOption(LoggingOptions.LOG_CONSOLE_FORMAT)
.isEnabled(LoggingPropertyMappers::isConsoleEnabled, CONSOLE_ENABLED_MSG)
.to("quarkus.log.console.format")
@ -73,6 +78,11 @@ public final class LoggingPropertyMappers {
.paramLabel("file")
.transformer(LoggingPropertyMappers::resolveFileLogLocation)
.build(),
fromOption(LoggingOptions.LOG_FILE_LEVEL)
.isEnabled(LoggingPropertyMappers::isFileEnabled, FILE_ENABLED_MSG)
.to("quarkus.log.file.level")
.paramLabel("level")
.build(),
fromOption(LoggingOptions.LOG_FILE_FORMAT)
.isEnabled(LoggingPropertyMappers::isFileEnabled, FILE_ENABLED_MSG)
.to("quarkus.log.file.format")
@ -107,6 +117,11 @@ public final class LoggingPropertyMappers {
.to("quarkus.log.syslog.endpoint")
.paramLabel("host:port")
.build(),
fromOption(LoggingOptions.LOG_SYSLOG_LEVEL)
.isEnabled(LoggingPropertyMappers::isSyslogEnabled, SYSLOG_ENABLED_MSG)
.to("quarkus.log.syslog.level")
.paramLabel("level")
.build(),
fromOption(LoggingOptions.LOG_SYSLOG_APP_NAME)
.isEnabled(LoggingPropertyMappers::isSyslogEnabled, SYSLOG_ENABLED_MSG)
.to("quarkus.log.syslog.app-name")

View file

@ -64,7 +64,7 @@ public class ConfigurationTest extends AbstractConfigurationTest {
@Test
public void testKeycloakConfPlaceholder() {
assertEquals("warn", createConfig().getRawValue("kc.log-level"));
assertEquals("info", createConfig().getRawValue("kc.log-level"));
putEnvVar("SOME_LOG_LEVEL", "debug");
assertEquals("debug", createConfig().getRawValue("kc.log-level"));
}
@ -476,7 +476,7 @@ public class ConfigurationTest extends AbstractConfigurationTest {
ConfigValue secret = config.getConfigValue("my.secret");
assertEquals("secret", secret.getValue());
}
@Test
public void testReloadPeriod() {
ConfigArgsConfigSource.setCliArgs("");

View file

@ -158,4 +158,30 @@ public class LoggingConfigurationTest extends AbstractConfigurationTest {
assertConfig("log-syslog-max-length", "512");
assertExternalConfig("quarkus.log.syslog.max-length", "512");
}
@Test
public void logLevelsHandlers() {
putEnvVars(Map.of(
"KC_LOG_LEVEL", "debug",
"KC_LOG_CONSOLE_LEVEL", "info",
"KC_LOG_SYSLOG_LEVEL", "trace",
"KC_LOG_FILE_LEVEL", "debug"
));
initConfig();
assertConfig(Map.of(
"log-level", "debug",
"log-console-level", "info",
"log-syslog-level", "trace",
"log-file-level", "debug"
));
assertExternalConfig(Map.of(
"quarkus.log.level", "DEBUG",
"quarkus.log.console.level", "info",
"quarkus.log.syslog.level", "trace",
"quarkus.log.file.level", "debug"
));
}
}

View file

@ -1,6 +1,6 @@
spi-hostname-default-frontend-url = ${keycloak.frontendUrl:http://filepropdefault.unittest}
%user-profile.spi-hostname-default-frontend-url = http://filepropprofile.unittest
log-level=${SOME_LOG_LEVEL:warn}
log-level=${SOME_LOG_LEVEL:info}
config-keystore=src/test/resources/keystore
config-keystore-password=secret

View file

@ -17,6 +17,10 @@
package org.keycloak.it.cli.dist;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.keycloak.quarkus.runtime.cli.command.Main.CONFIG_FILE_LONG_NAME;
@ -118,11 +122,8 @@ public class LoggingDistTest {
@Test
@Launch({ "start-dev", "--log=console,file", "--log-file-format=\"%d{HH:mm:ss} %-5p [%c{1.}] (%t) %s%e%n\""})
void testFileLoggingHasDifferentFormat(RawDistRootPath path) throws IOException {
Path logFilePath = Paths.get(path.getDistRootPath() + File.separator + LoggingOptions.DEFAULT_LOG_PATH);
File logFile = new File(logFilePath.toString());
String data = FileUtils.readFileToString(logFile, Charset.defaultCharset());
void testFileLoggingHasDifferentFormat(RawDistRootPath path) {
String data = readDefaultFileLog(path);
assertTrue(data.contains("INFO [i.quarkus] (main)"), "Format not applied");
}
@ -169,4 +170,79 @@ public class LoggingDistTest {
cliResult.assertNoMessage("Listening on:");
cliResult.assertError("Error writing to TCP stream");
}
@Test
@Launch({"start-dev", "--log-console-level=wrong"})
void wrongLevelForHandlers(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
cliResult.assertError("Invalid value for option '--log-console-level': wrong. Expected values are: off, fatal, error, warn, info, debug, trace, all");
}
@Test
@Launch({"start-dev", "--log=console,file", "--log-console-level=debug", "--log-file-level=debug"})
void levelRootDefault(LaunchResult result, RawDistRootPath path) {
CLIResult cliResult = (CLIResult) result;
var output = cliResult.getOutput();
assertThat(output, not(containsString("DEBUG [org.hibernate")));
assertThat(output, not(containsString("DEBUG [org.keycloak")));
var fileLog = readDefaultFileLog(path);
assertThat(fileLog, notNullValue());
assertFalse(fileLog.isBlank());
assertThat(fileLog, not(containsString("DEBUG [org.hibernate")));
assertThat(fileLog, not(containsString("DEBUG [org.keycloak")));
assertThat(fileLog, containsString("INFO [io.quarkus]"));
assertThat(fileLog, containsString("INFO [org.keycloak"));
}
@Test
@Launch({"start-dev", "--log=console,file", "--log-level=org.keycloak:debug", "--log-console-level=debug", "--log-file-level=debug"})
void levelRootCategoryDebug(LaunchResult result, RawDistRootPath path) {
CLIResult cliResult = (CLIResult) result;
var output = cliResult.getOutput();
assertThat(output, not(containsString("DEBUG [org.hibernate")));
assertThat(output, containsString("DEBUG [org.keycloak"));
var fileLog = readDefaultFileLog(path);
assertThat(fileLog, notNullValue());
assertFalse(fileLog.isBlank());
assertThat(fileLog, not(containsString("DEBUG [org.hibernate")));
assertThat(fileLog, containsString("DEBUG [org.keycloak"));
assertThat(fileLog, containsString("INFO [io.quarkus]"));
assertThat(fileLog, containsString("INFO [org.keycloak"));
}
@Test
@Launch({"start-dev", "--log=console,file", "--log-level=info,org.keycloak:warn", "--log-console-level=off", "--log-file-level=off"})
void levelOffHandlers(LaunchResult result, RawDistRootPath path) {
CLIResult cliResult = (CLIResult) result;
var output = cliResult.getOutput();
// log contains DB migration status + build time logs
assertThat(output, not(containsString("DEBUG [org.hibernate")));
assertThat(output, not(containsString("INFO [org.keycloak")));
assertThat(output, not(containsString("INFO [io.quarkus")));
var fileLog = readDefaultFileLog(path);
assertThat(fileLog, notNullValue());
assertTrue(fileLog.isBlank());
}
protected static String readDefaultFileLog(RawDistRootPath path) {
Path logFilePath = Paths.get(path.getDistRootPath() + File.separator + LoggingOptions.DEFAULT_LOG_PATH);
File logFile = new File(logFilePath.toString());
assertTrue(logFile.isFile(), "Log file does not exist!");
try {
return FileUtils.readFileToString(logFile, Charset.defaultCharset());
} catch (IOException e) {
throw new AssertionError("Cannot read default file log", e);
}
}
}

View file

@ -58,7 +58,7 @@ public class OptionsDistTest {
@Launch({"start", "--log=console", "--log-file-output=json", "--http-enabled=true", "--hostname-strict=false"})
public void testServerDoesNotStartIfDisabledFileLogOption(LaunchResult result) {
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Disabled option: '--log-file-output'. Available only when File log handler is activated")).count());
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Possible solutions: --log, --log-console-output, --log-console-format, --log-console-color")).count());
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Possible solutions: --log, --log-console-output, --log-console-level, --log-console-format, --log-console-color, --log-level")).count());
}
@Test
@ -110,7 +110,7 @@ public class OptionsDistTest {
@Launch({"start-dev", "--log=console", "--log-file-output=json"})
public void testServerDoesNotStartDevIfDisabledFileLogOption(LaunchResult result) {
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Disabled option: '--log-file-output'. Available only when File log handler is activated")).count());
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Possible solutions: --log, --log-console-output, --log-console-format, --log-console-color")).count());
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Possible solutions: --log, --log-console-output, --log-console-level, --log-console-format, --log-console-color, --log-level")).count());
}
@Test
@ -119,6 +119,6 @@ public class OptionsDistTest {
public void testServerStartDevIfEnabledFileLogOption(LaunchResult result) {
assertEquals(0, result.getErrorStream().stream().filter(s -> s.contains("Disabled option: '--log-file-output'. Available only when File log handler is activated")).count());
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Disabled option: '--log-console-color'. Available only when Console log handler is activated")).count());
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Possible solutions: --log, --log-file, --log-file-format, --log-file-output, --log-level")).count());
assertEquals(1, result.getErrorStream().stream().filter(s -> s.contains("Possible solutions: --log, --log-file, --log-file-level, --log-file-format, --log-file-output, --log-level")).count());
}
}

View file

@ -17,8 +17,9 @@
package org.keycloak.it.cli.dist;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.function.Consumer;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
@ -48,23 +49,24 @@ public class QuarkusPropertiesAutoBuildDistTest {
}
@Test
@BeforeStartDistribution(QuarkusPropertiesAutoBuildDistTest.UpdateConsoleLogLevelToWarn.class)
@BeforeStartDistribution(EnableAdditionalConsoleHandler.class)
@Launch({ "start" })
@Order(2)
void testQuarkusRuntimePropDoesNotTriggerReAug(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
cliResult.assertNoBuild();
assertFalse(cliResult.getOutput().contains("INFO [io.quarkus]"));
assertThat(cliResult.getOutput(), containsString("Keycloak is the best"));
}
@Test
@BeforeStartDistribution(UpdateConsoleLogLevelToInfo.class)
@BeforeStartDistribution(DisableAdditionalConsoleHandler.class)
@Launch({ "start" })
@Order(3)
void testNoReAugAfterChangingRuntimeProperty(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
cliResult.assertNoBuild();
assertTrue(cliResult.getOutput().contains("INFO [io.quarkus]"));
assertThat(cliResult.getOutput(), not(containsString("Keycloak is the best")));
}
@Test
@ -122,18 +124,20 @@ public class QuarkusPropertiesAutoBuildDistTest {
cliResult.assertError("Multiple datasources are configured but more than 1 is using non-XA transactions.");
}
public static class UpdateConsoleLogLevelToWarn implements Consumer<KeycloakDistribution> {
public static class EnableAdditionalConsoleHandler implements Consumer<KeycloakDistribution> {
@Override
public void accept(KeycloakDistribution distribution) {
distribution.setQuarkusProperty("quarkus.log.console.level", "WARN");
distribution.setQuarkusProperty("quarkus.log.handler.console.\"console-2\".enable", "true");
distribution.setQuarkusProperty("quarkus.log.handler.console.\"console-2\".format", "Keycloak is the best");
distribution.setQuarkusProperty("quarkus.log.handlers", "console-2");
}
}
public static class UpdateConsoleLogLevelToInfo implements Consumer<KeycloakDistribution> {
public static class DisableAdditionalConsoleHandler implements Consumer<KeycloakDistribution> {
@Override
public void accept(KeycloakDistribution distribution) {
distribution.setQuarkusProperty("quarkus.log.console.level", "INFO");
distribution.setQuarkusProperty("quarkus.log.handler.console.\"console-2\".enable", "false");
}
}

View file

@ -17,15 +17,8 @@
package org.keycloak.it.cli.dist;
import static io.restassured.RestAssured.when;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG;
import java.util.Optional;
import java.util.function.Consumer;
import io.quarkus.test.junit.main.Launch;
import io.quarkus.test.junit.main.LaunchResult;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
@ -41,8 +34,15 @@ import org.keycloak.it.junit5.extension.KeepServerAlive;
import org.keycloak.it.junit5.extension.RawDistOnly;
import org.keycloak.it.utils.KeycloakDistribution;
import io.quarkus.test.junit.main.Launch;
import io.quarkus.test.junit.main.LaunchResult;
import java.util.Optional;
import java.util.function.Consumer;
import static io.restassured.RestAssured.when;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG;
@DistributionTest(reInstall = DistributionTest.ReInstall.NEVER)
@RawDistOnly(reason = "Containers are immutable")
@ -50,10 +50,10 @@ import io.quarkus.test.junit.main.LaunchResult;
public class QuarkusPropertiesDistTest {
private static final String QUARKUS_BUILDTIME_HIBERNATE_METRICS_KEY = "quarkus.datasource.metrics.enabled";
private static final String QUARKUS_RUNTIME_CONSOLE_LOGLVL_KEY = "quarkus.log.console.level";
private static final String QUARKUS_RUNTIME_CONSOLE_HANDLER_ENABLED_KEY = "quarkus.log.handler.console.\"console-2\".enable";
@Test
@Launch({ "build" })
@Launch({"build"})
@Order(1)
void testBuildWithPropertyFromQuarkusProperties(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
@ -61,48 +61,48 @@ public class QuarkusPropertiesDistTest {
}
@Test
@BeforeStartDistribution(QuarkusPropertiesDistTest.UpdateConsoleLogLevelToWarnFromQuarkusProps.class)
@Launch({ "start", "--http-enabled=true", "--hostname-strict=false" })
@BeforeStartDistribution(QuarkusPropertiesDistTest.AddConsoleHandlerFromQuarkusProps.class)
@Launch({"start", "--http-enabled=true", "--hostname-strict=false"})
@Order(2)
void testPropertyEnabledAtRuntime(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
assertFalse(cliResult.getOutput().contains("INFO"));
assertThat(cliResult.getOutput(), containsString("Keycloak is the best"));
}
@Test
@Launch({ "-Dquarkus.log.console.level=info", "start", "--http-enabled=true", "--hostname-strict=false" })
@Launch({"-Dquarkus.log.handler.console.\"console-2\".enable=false", "start", "--http-enabled=true", "--hostname-strict=false"})
@Order(3)
void testIgnoreQuarkusSystemPropertiesAtStart(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
assertFalse(cliResult.getOutput().contains("INFO"));
assertThat(cliResult.getOutput(), containsString("Keycloak is the best"));
}
@Test
@Launch({ "-Dquarkus.log.console.level=info", "build" })
@Launch({"-Dquarkus.log.handler.console.\"console-2\".enable=false", "build"})
@Order(4)
void testIgnoreQuarkusSystemPropertyAtBuild(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
assertFalse(cliResult.getOutput().contains("INFO"));
assertThat(cliResult.getOutput(), containsString("Keycloak is the best"));
cliResult.assertBuild();
}
@Test
@BeforeStartDistribution(UpdateConsoleLogLevelToInfoFromKeycloakConf.class)
@Launch({ "build" })
@BeforeStartDistribution(UpdateConsoleHandlerFromKeycloakConf.class)
@Launch({"build"})
@Order(5)
void testIgnoreQuarkusPropertyFromKeycloakConf(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
assertTrue(cliResult.getOutput().contains("INFO"));
assertThat(cliResult.getOutput(), not(containsString("Keycloak is the best")));
cliResult.assertBuild();
}
@Test
@BeforeStartDistribution(UpdateConsoleLogLevelToInfoFromQuarkusProps.class)
@Launch({ "start", "--http-enabled=true", "--hostname-strict=false" })
@BeforeStartDistribution(UpdateConsoleHandlerFromQuarkusProps.class)
@Launch({"start", "--http-enabled=true", "--hostname-strict=false"})
@Order(6)
void testRuntimePropFromQuarkusPropsIsAppliedWithoutRebuild(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
assertTrue(cliResult.getOutput().contains("INFO"));
assertThat(cliResult.getOutput(), not(containsString("Keycloak is the best")));
cliResult.assertNoBuild();
}
@ -166,7 +166,7 @@ public class QuarkusPropertiesDistTest {
void testSmallRyeKeyStoreConfigSource(LaunchResult result) {
// keytool -importpass -alias kc.log-level -keystore keystore -storepass secret -storetype PKCS12 -v (with "debug" as the stored password)
CLIResult cliResult = (CLIResult) result;
assertTrue(cliResult.getOutput().contains("DEBUG"));
assertThat(cliResult.getOutput(),containsString("DEBUG"));
cliResult.assertStarted();
}
@ -179,7 +179,7 @@ public class QuarkusPropertiesDistTest {
@Order(13)
void testHttpCertsPathTransformer(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
assertTrue(cliResult.getOutput().contains("ERROR: /tmp/kc/bin/../conf/server.crt.pem"));
assertThat(cliResult.getOutput(),containsString("ERROR: /tmp/kc/bin/../conf/server.crt.pem"));
}
@Test
@ -191,31 +191,33 @@ public class QuarkusPropertiesDistTest {
@Order(14)
void testHttpCertsPathTransformerOnWindows(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
assertTrue(cliResult.getOutput().contains("ERROR: C:/tmp/kc/bin/../conf/server.crt.pem"));
assertThat(cliResult.getOutput(),containsString("ERROR: C:/tmp/kc/bin/../conf/server.crt.pem"));
}
public static class UpdateConsoleLogLevelToWarnFromQuarkusProps implements Consumer<KeycloakDistribution> {
public static class AddConsoleHandlerFromQuarkusProps implements Consumer<KeycloakDistribution> {
@Override
public void accept(KeycloakDistribution distribution) {
distribution.setQuarkusProperty(QUARKUS_RUNTIME_CONSOLE_LOGLVL_KEY, "WARN");
distribution.setQuarkusProperty(QUARKUS_RUNTIME_CONSOLE_HANDLER_ENABLED_KEY, "true");
distribution.setQuarkusProperty("quarkus.log.handler.console.\"console-2\".format", "Keycloak is the best");
distribution.setQuarkusProperty("quarkus.log.handlers", "console-2");
}
}
public static class UpdateConsoleLogLevelToInfoFromKeycloakConf implements Consumer<KeycloakDistribution> {
public static class UpdateConsoleHandlerFromKeycloakConf implements Consumer<KeycloakDistribution> {
@Override
public void accept(KeycloakDistribution distribution) {
distribution.deleteQuarkusProperties();
distribution.setProperty(QUARKUS_RUNTIME_CONSOLE_LOGLVL_KEY, "INFO");
distribution.setProperty(QUARKUS_RUNTIME_CONSOLE_HANDLER_ENABLED_KEY, "false");
}
}
public static class UpdateConsoleLogLevelToInfoFromQuarkusProps implements Consumer<KeycloakDistribution> {
public static class UpdateConsoleHandlerFromQuarkusProps implements Consumer<KeycloakDistribution> {
@Override
public void accept(KeycloakDistribution distribution) {
distribution.deleteQuarkusProperties();
distribution.setQuarkusProperty(QUARKUS_RUNTIME_CONSOLE_LOGLVL_KEY, "INFO");
distribution.setQuarkusProperty(QUARKUS_RUNTIME_CONSOLE_HANDLER_ENABLED_KEY, "true");
}
}
@ -236,4 +238,4 @@ public class QuarkusPropertiesDistTest {
buildResult.assertBuild();
}
}
}
}

View file

@ -127,6 +127,13 @@ Logging:
The format of unstructured console log entries. If the format has spaces in
it, escape the value using "<format>". Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
-5p [%c] (%t) %s%e%n. Available only when Console log handler is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log

View file

@ -131,6 +131,13 @@ Logging:
Include tracing information in the console log. If the 'log-console-format'
option is specified, this option has no effect. Default: true. Available
only when Console log handler and Tracing is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log
@ -145,6 +152,13 @@ Logging:
Include tracing information in the file log. If the 'log-file-format' option
is specified, this option has no effect. Default: true. Available only when
File log handler and Tracing is activated.
--log-file-level <level>
Set the log level for the file handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when File log handler is activated.
--log-file-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when File log
@ -166,6 +180,13 @@ Logging:
Include tracing information in the Syslog. If the 'log-syslog-format' option
is specified, this option has no effect. Default: true. Available only when
Syslog handler and Tracing is activated.
--log-syslog-level <level>
Set the log level for the Syslog handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Syslog is activated.
--log-syslog-max-length <max-length>
Set the maximum length, in bytes, of the message allowed to be sent. The
length includes the header and the message. If not set, the default value is

View file

@ -127,6 +127,13 @@ Logging:
The format of unstructured console log entries. If the format has spaces in
it, escape the value using "<format>". Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
-5p [%c] (%t) %s%e%n. Available only when Console log handler is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log

View file

@ -131,6 +131,13 @@ Logging:
Include tracing information in the console log. If the 'log-console-format'
option is specified, this option has no effect. Default: true. Available
only when Console log handler and Tracing is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log
@ -145,6 +152,13 @@ Logging:
Include tracing information in the file log. If the 'log-file-format' option
is specified, this option has no effect. Default: true. Available only when
File log handler and Tracing is activated.
--log-file-level <level>
Set the log level for the file handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when File log handler is activated.
--log-file-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when File log
@ -166,6 +180,13 @@ Logging:
Include tracing information in the Syslog. If the 'log-syslog-format' option
is specified, this option has no effect. Default: true. Available only when
Syslog handler and Tracing is activated.
--log-syslog-level <level>
Set the log level for the Syslog handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Syslog is activated.
--log-syslog-max-length <max-length>
Set the maximum length, in bytes, of the message allowed to be sent. The
length includes the header and the message. If not set, the default value is

View file

@ -273,6 +273,13 @@ Logging:
The format of unstructured console log entries. If the format has spaces in
it, escape the value using "<format>". Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
-5p [%c] (%t) %s%e%n. Available only when Console log handler is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log

View file

@ -312,6 +312,13 @@ Logging:
Include tracing information in the console log. If the 'log-console-format'
option is specified, this option has no effect. Default: true. Available
only when Console log handler and Tracing is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log
@ -326,6 +333,13 @@ Logging:
Include tracing information in the file log. If the 'log-file-format' option
is specified, this option has no effect. Default: true. Available only when
File log handler and Tracing is activated.
--log-file-level <level>
Set the log level for the file handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when File log handler is activated.
--log-file-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when File log
@ -347,6 +361,13 @@ Logging:
Include tracing information in the Syslog. If the 'log-syslog-format' option
is specified, this option has no effect. Default: true. Available only when
Syslog handler and Tracing is activated.
--log-syslog-level <level>
Set the log level for the Syslog handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Syslog is activated.
--log-syslog-max-length <max-length>
Set the maximum length, in bytes, of the message allowed to be sent. The
length includes the header and the message. If not set, the default value is

View file

@ -274,6 +274,13 @@ Logging:
The format of unstructured console log entries. If the format has spaces in
it, escape the value using "<format>". Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
-5p [%c] (%t) %s%e%n. Available only when Console log handler is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log

View file

@ -313,6 +313,13 @@ Logging:
Include tracing information in the console log. If the 'log-console-format'
option is specified, this option has no effect. Default: true. Available
only when Console log handler and Tracing is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log
@ -327,6 +334,13 @@ Logging:
Include tracing information in the file log. If the 'log-file-format' option
is specified, this option has no effect. Default: true. Available only when
File log handler and Tracing is activated.
--log-file-level <level>
Set the log level for the file handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when File log handler is activated.
--log-file-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when File log
@ -348,6 +362,13 @@ Logging:
Include tracing information in the Syslog. If the 'log-syslog-format' option
is specified, this option has no effect. Default: true. Available only when
Syslog handler and Tracing is activated.
--log-syslog-level <level>
Set the log level for the Syslog handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Syslog is activated.
--log-syslog-max-length <max-length>
Set the maximum length, in bytes, of the message allowed to be sent. The
length includes the header and the message. If not set, the default value is

View file

@ -225,6 +225,13 @@ Logging:
The format of unstructured console log entries. If the format has spaces in
it, escape the value using "<format>". Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
-5p [%c] (%t) %s%e%n. Available only when Console log handler is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log

View file

@ -264,6 +264,13 @@ Logging:
Include tracing information in the console log. If the 'log-console-format'
option is specified, this option has no effect. Default: true. Available
only when Console log handler and Tracing is activated.
--log-console-level <level>
Set the log level for the console handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Console log handler is activated.
--log-console-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when Console log
@ -278,6 +285,13 @@ Logging:
Include tracing information in the file log. If the 'log-file-format' option
is specified, this option has no effect. Default: true. Available only when
File log handler and Tracing is activated.
--log-file-level <level>
Set the log level for the file handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when File log handler is activated.
--log-file-output <output>
Set the log output to JSON or default (plain) unstructured logging. Possible
values are: default, json. Default: default. Available only when File log
@ -299,6 +313,13 @@ Logging:
Include tracing information in the Syslog. If the 'log-syslog-format' option
is specified, this option has no effect. Default: true. Available only when
Syslog handler and Tracing is activated.
--log-syslog-level <level>
Set the log level for the Syslog handler. It specifies the most verbose log
level for logs shown in the output. It respects levels specified in the
'log-level' option, which represents the maximal verbosity for the whole
logging system. For more information, check the Logging guide. Possible
values are: off, fatal, error, warn, info, debug, trace, all. Default: all.
Available only when Syslog is activated.
--log-syslog-max-length <max-length>
Set the maximum length, in bytes, of the message allowed to be sent. The
length includes the header and the message. If not set, the default value is