Syslog: add necessary options to cover the major usability (#32316)
Closes #32314 Signed-off-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
parent
9454c01d88
commit
f6d880ea3f
11 changed files with 296 additions and 104 deletions
|
@ -2,6 +2,7 @@
|
||||||
<#import "/templates/kc.adoc" as kc>
|
<#import "/templates/kc.adoc" as kc>
|
||||||
<#import "/templates/links.adoc" as links>
|
<#import "/templates/links.adoc" as links>
|
||||||
<#import "/templates/profile.adoc" as profile>
|
<#import "/templates/profile.adoc" as profile>
|
||||||
|
<#import "/templates/options.adoc" as opts>
|
||||||
|
|
||||||
<@tmpl.guide
|
<@tmpl.guide
|
||||||
title="Configuring logging"
|
title="Configuring logging"
|
||||||
|
@ -235,6 +236,33 @@ Note that you need to escape characters when invoking commands containing specia
|
||||||
|
|
||||||
This example abbreviates the category name to three characters by setting `[%c{3.}]` in the template instead of the default `[%c]`.
|
This example abbreviates the category name to three characters by setting `[%c{3.}]` in the template instead of the default `[%c]`.
|
||||||
|
|
||||||
|
=== Configuring the Syslog type
|
||||||
|
|
||||||
|
Syslog uses different message formats based on particular RFC specifications.
|
||||||
|
To change the Syslog type with a different message format, use the `--log-syslog-type` option as follows:
|
||||||
|
|
||||||
|
<@kc.start parameters="--log-syslog-type=rfc3164"/>
|
||||||
|
|
||||||
|
Possible values for the `--log-syslog-type` option are:
|
||||||
|
|
||||||
|
<@opts.expectedValues option="log-syslog-type"/>
|
||||||
|
|
||||||
|
The preferred Syslog type is https://datatracker.ietf.org/doc/html/rfc5424[RFC 5424], which obsoletes https://datatracker.ietf.org/doc/html/rfc3164[RFC 3164], known as BSD Syslog protocol.
|
||||||
|
|
||||||
|
=== Configuring the Syslog maximum message length
|
||||||
|
|
||||||
|
To set the maximum length of the message allowed to be sent (in bytes), use the `--log-syslog-max-length` option as follows:
|
||||||
|
|
||||||
|
<@kc.start parameters="--log-syslog-max-length=1536"/>
|
||||||
|
|
||||||
|
The length can be specified in memory size format with the appropriate suffix, like `1k` or `1K`.
|
||||||
|
The length includes the header and the message.
|
||||||
|
|
||||||
|
If the length is not explicitly set, the default values are set based on the `--log-syslog-type` option as follows:
|
||||||
|
|
||||||
|
* `2048B` - for RFC 5424
|
||||||
|
* `1024B` - for RFC 3164
|
||||||
|
|
||||||
=== Configuring the Syslog structured output
|
=== Configuring the Syslog structured output
|
||||||
By default, the Syslog log handler sends plain unstructured data to the Syslog server.
|
By default, the Syslog log handler sends plain unstructured data to the Syslog server.
|
||||||
To use structured JSON log output instead, enter the following command:
|
To use structured JSON log output instead, enter the following command:
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package org.keycloak.config;
|
package org.keycloak.config;
|
||||||
|
|
||||||
|
import io.quarkus.runtime.configuration.MemorySize;
|
||||||
|
import org.jboss.logmanager.handlers.SyslogHandler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
|
|
||||||
|
@ -137,39 +138,53 @@ public class LoggingOptions {
|
||||||
|
|
||||||
public static final Option<String> LOG_SYSLOG_ENDPOINT = new OptionBuilder<>("log-syslog-endpoint", String.class)
|
public static final Option<String> LOG_SYSLOG_ENDPOINT = new OptionBuilder<>("log-syslog-endpoint", String.class)
|
||||||
.category(OptionCategory.LOGGING)
|
.category(OptionCategory.LOGGING)
|
||||||
.description("The IP address and port of the syslog server.")
|
.description("Set the IP address and port of the Syslog server.")
|
||||||
.defaultValue("localhost:514")
|
.defaultValue("localhost:514")
|
||||||
.build();
|
.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())
|
||||||
|
.description("Set the Syslog type used to format the sent message.")
|
||||||
|
.defaultValue(SyslogHandler.SyslogType.RFC5424.toString().toLowerCase())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public static final Option<MemorySize> LOG_SYSLOG_MAX_LENGTH = new OptionBuilder<>("log-syslog-max-length", MemorySize.class)
|
||||||
|
.category(OptionCategory.LOGGING)
|
||||||
|
// based on the 'quarkus.log.syslog.max-length' property
|
||||||
|
.description("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 2048 when 'log-syslog-type' is rfc5424 (default) and 1024 when 'log-syslog-type' is rfc3164.")
|
||||||
|
.build();
|
||||||
|
|
||||||
public static final Option<String> LOG_SYSLOG_APP_NAME = new OptionBuilder<>("log-syslog-app-name", String.class)
|
public static final Option<String> LOG_SYSLOG_APP_NAME = new OptionBuilder<>("log-syslog-app-name", String.class)
|
||||||
.category(OptionCategory.LOGGING)
|
.category(OptionCategory.LOGGING)
|
||||||
.description("The app name used when formatting the message in RFC5424 format.")
|
.description("Set the app name used when formatting the message in RFC5424 format.")
|
||||||
.defaultValue("keycloak")
|
.defaultValue("keycloak")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final Option<String> LOG_SYSLOG_PROTOCOL = new OptionBuilder<>("log-syslog-protocol", String.class)
|
public static final Option<String> LOG_SYSLOG_PROTOCOL = new OptionBuilder<>("log-syslog-protocol", String.class)
|
||||||
.category(OptionCategory.LOGGING)
|
.category(OptionCategory.LOGGING)
|
||||||
.description("Sets the protocol used to connect to the syslog server.")
|
.description("Set the protocol used to connect to the Syslog server.")
|
||||||
.defaultValue("tcp")
|
.defaultValue("tcp")
|
||||||
.expectedValues("tcp", "udp", "ssl-tcp")
|
.expectedValues("tcp", "udp", "ssl-tcp")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final Option<String> LOG_SYSLOG_FORMAT = new OptionBuilder<>("log-syslog-format", String.class)
|
public static final Option<String> LOG_SYSLOG_FORMAT = new OptionBuilder<>("log-syslog-format", String.class)
|
||||||
.category(OptionCategory.LOGGING)
|
.category(OptionCategory.LOGGING)
|
||||||
.description("Set a format specific to syslog entries.")
|
.description("Set a format specific to Syslog entries.")
|
||||||
.defaultValue(DEFAULT_LOG_FORMAT)
|
.defaultValue(DEFAULT_LOG_FORMAT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final Option<Boolean> LOG_SYSLOG_INCLUDE_TRACE = new OptionBuilder<>("log-syslog-include-trace", Boolean.class)
|
public static final Option<Boolean> LOG_SYSLOG_INCLUDE_TRACE = new OptionBuilder<>("log-syslog-include-trace", Boolean.class)
|
||||||
.category(OptionCategory.LOGGING)
|
.category(OptionCategory.LOGGING)
|
||||||
.description(format("Include tracing information in the syslog. If the '%s' option is specified, this option has no effect.", LOG_SYSLOG_FORMAT.getKey()))
|
.description(format("Include tracing information in the Syslog. If the '%s' option is specified, this option has no effect.", LOG_SYSLOG_FORMAT.getKey()))
|
||||||
.defaultValue(true)
|
.defaultValue(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final Option<Output> LOG_SYSLOG_OUTPUT = new OptionBuilder<>("log-syslog-output", Output.class)
|
public static final Option<Output> LOG_SYSLOG_OUTPUT = new OptionBuilder<>("log-syslog-output", Output.class)
|
||||||
.category(OptionCategory.LOGGING)
|
.category(OptionCategory.LOGGING)
|
||||||
.defaultValue(DEFAULT_SYSLOG_OUTPUT)
|
.defaultValue(DEFAULT_SYSLOG_OUTPUT)
|
||||||
.description("Set the syslog output to JSON or default (plain) unstructured logging.")
|
.description("Set the Syslog output to JSON or default (plain) unstructured logging.")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,10 @@ public final class Configuration {
|
||||||
return getOptionalValue(NS_KEYCLOAK_PREFIX.concat(propertyName));
|
return getOptionalValue(NS_KEYCLOAK_PREFIX.concat(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Optional<String> getOptionalKcValue(Option<?> option) {
|
||||||
|
return getOptionalKcValue(option.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<Boolean> getOptionalBooleanKcValue(String propertyName) {
|
public static Optional<Boolean> getOptionalBooleanKcValue(String propertyName) {
|
||||||
return getOptionalValue(NS_KEYCLOAK_PREFIX.concat(propertyName)).map(Boolean::parseBoolean);
|
return getOptionalValue(NS_KEYCLOAK_PREFIX.concat(propertyName)).map(Boolean::parseBoolean);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.stream.Stream;
|
||||||
import org.jboss.logmanager.LogContext;
|
import org.jboss.logmanager.LogContext;
|
||||||
import org.keycloak.config.LoggingOptions;
|
import org.keycloak.config.LoggingOptions;
|
||||||
import org.keycloak.config.Option;
|
import org.keycloak.config.Option;
|
||||||
import org.keycloak.config.TracingOptions;
|
|
||||||
import org.keycloak.quarkus.runtime.Messages;
|
import org.keycloak.quarkus.runtime.Messages;
|
||||||
import org.keycloak.quarkus.runtime.cli.PropertyException;
|
import org.keycloak.quarkus.runtime.cli.PropertyException;
|
||||||
|
|
||||||
|
@ -113,6 +112,16 @@ public final class LoggingPropertyMappers {
|
||||||
.to("quarkus.log.syslog.app-name")
|
.to("quarkus.log.syslog.app-name")
|
||||||
.paramLabel("name")
|
.paramLabel("name")
|
||||||
.build(),
|
.build(),
|
||||||
|
fromOption(LoggingOptions.LOG_SYSLOG_TYPE)
|
||||||
|
.isEnabled(LoggingPropertyMappers::isSyslogEnabled, SYSLOG_ENABLED_MSG)
|
||||||
|
.to("quarkus.log.syslog.syslog-type")
|
||||||
|
.paramLabel("type")
|
||||||
|
.build(),
|
||||||
|
fromOption(LoggingOptions.LOG_SYSLOG_MAX_LENGTH)
|
||||||
|
.isEnabled(LoggingPropertyMappers::isSyslogEnabled, SYSLOG_ENABLED_MSG)
|
||||||
|
.to("quarkus.log.syslog.max-length")
|
||||||
|
.paramLabel("max-length")
|
||||||
|
.build(),
|
||||||
fromOption(LoggingOptions.LOG_SYSLOG_PROTOCOL)
|
fromOption(LoggingOptions.LOG_SYSLOG_PROTOCOL)
|
||||||
.isEnabled(LoggingPropertyMappers::isSyslogEnabled, SYSLOG_ENABLED_MSG)
|
.isEnabled(LoggingPropertyMappers::isSyslogEnabled, SYSLOG_ENABLED_MSG)
|
||||||
.to("quarkus.log.syslog.protocol")
|
.to("quarkus.log.syslog.protocol")
|
||||||
|
|
|
@ -430,71 +430,6 @@ public class ConfigurationTest extends AbstractConfigurationTest {
|
||||||
assertEquals("true", config.getConfigValue("quarkus.datasource.metrics.enabled").getValue());
|
assertEquals("true", config.getConfigValue("quarkus.datasource.metrics.enabled").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLogHandlerConfig() {
|
|
||||||
ConfigArgsConfigSource.setCliArgs("--log=console,file");
|
|
||||||
SmallRyeConfig config = createConfig();
|
|
||||||
assertEquals("true", config.getConfigValue("quarkus.log.console.enable").getValue());
|
|
||||||
assertEquals("true", config.getConfigValue("quarkus.log.file.enable").getValue());
|
|
||||||
assertEquals("false", config.getConfigValue("quarkus.log.syslog.enable").getValue());
|
|
||||||
|
|
||||||
ConfigArgsConfigSource.setCliArgs("--log=file");
|
|
||||||
SmallRyeConfig config2 = createConfig();
|
|
||||||
assertEquals("false", config2.getConfigValue("quarkus.log.console.enable").getValue());
|
|
||||||
assertEquals("true", config2.getConfigValue("quarkus.log.file.enable").getValue());
|
|
||||||
assertEquals("false", config2.getConfigValue("quarkus.log.syslog.enable").getValue());
|
|
||||||
|
|
||||||
ConfigArgsConfigSource.setCliArgs("--log=console");
|
|
||||||
SmallRyeConfig config3 = createConfig();
|
|
||||||
assertEquals("true", config3.getConfigValue("quarkus.log.console.enable").getValue());
|
|
||||||
assertEquals("false", config3.getConfigValue("quarkus.log.file.enable").getValue());
|
|
||||||
assertEquals("false", config3.getConfigValue("quarkus.log.syslog.enable").getValue());
|
|
||||||
|
|
||||||
ConfigArgsConfigSource.setCliArgs("--log=console,syslog");
|
|
||||||
SmallRyeConfig config5 = createConfig();
|
|
||||||
assertEquals("true", config5.getConfigValue("quarkus.log.console.enable").getValue());
|
|
||||||
assertEquals("false", config5.getConfigValue("quarkus.log.file.enable").getValue());
|
|
||||||
assertEquals("true", config5.getConfigValue("quarkus.log.syslog.enable").getValue());
|
|
||||||
|
|
||||||
ConfigArgsConfigSource.setCliArgs("--log=syslog");
|
|
||||||
SmallRyeConfig config6 = createConfig();
|
|
||||||
assertEquals("false", config6.getConfigValue("quarkus.log.console.enable").getValue());
|
|
||||||
assertEquals("false", config6.getConfigValue("quarkus.log.file.enable").getValue());
|
|
||||||
assertEquals("true", config6.getConfigValue("quarkus.log.syslog.enable").getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSyslogProperties() {
|
|
||||||
putEnvVars(Map.of(
|
|
||||||
"KC_LOG", "syslog",
|
|
||||||
"KC_LOG_SYSLOG_ENDPOINT", "192.168.0.42:515",
|
|
||||||
"KC_LOG_SYSLOG_APP_NAME", "keycloak2",
|
|
||||||
"KC_LOG_SYSLOG_PROTOCOL", "udp",
|
|
||||||
"KC_LOG_SYSLOG_FORMAT", "some format",
|
|
||||||
"KC_LOG_SYSLOG_OUTPUT", "json"
|
|
||||||
));
|
|
||||||
|
|
||||||
initConfig();
|
|
||||||
|
|
||||||
assertConfig(Map.of(
|
|
||||||
"log-syslog-enabled", "true",
|
|
||||||
"log-syslog-endpoint", "192.168.0.42:515",
|
|
||||||
"log-syslog-app-name", "keycloak2",
|
|
||||||
"log-syslog-protocol", "udp",
|
|
||||||
"log-syslog-format", "some format",
|
|
||||||
"log-syslog-output", "json"
|
|
||||||
));
|
|
||||||
|
|
||||||
assertExternalConfig(Map.of(
|
|
||||||
"quarkus.log.syslog.enable", "true",
|
|
||||||
"quarkus.log.syslog.endpoint", "192.168.0.42:515",
|
|
||||||
"quarkus.log.syslog.app-name", "keycloak2",
|
|
||||||
"quarkus.log.syslog.protocol", "udp",
|
|
||||||
"quarkus.log.syslog.format", "some format",
|
|
||||||
"quarkus.log.syslog.json", "true"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOptionValueWithEqualSign() {
|
public void testOptionValueWithEqualSign() {
|
||||||
ConfigArgsConfigSource.setCliArgs("--db=postgres", "--db-password=my_secret=");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres", "--db-password=my_secret=");
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2024 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.quarkus.runtime.configuration.test;
|
||||||
|
|
||||||
|
import io.smallrye.config.SmallRyeConfig;
|
||||||
|
import org.hamcrest.CoreMatchers;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.keycloak.config.LoggingOptions;
|
||||||
|
import org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource;
|
||||||
|
import org.keycloak.quarkus.runtime.configuration.Configuration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.keycloak.config.LoggingOptions.DEFAULT_LOG_FORMAT;
|
||||||
|
import static org.keycloak.config.LoggingOptions.DEFAULT_SYSLOG_OUTPUT;
|
||||||
|
|
||||||
|
public class LoggingConfigurationTest extends AbstractConfigurationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logHandlerConfig() {
|
||||||
|
ConfigArgsConfigSource.setCliArgs("--log=console,file");
|
||||||
|
SmallRyeConfig config = createConfig();
|
||||||
|
assertEquals("true", config.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
|
assertEquals("true", config.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
|
assertEquals("false", config.getConfigValue("quarkus.log.syslog.enable").getValue());
|
||||||
|
|
||||||
|
ConfigArgsConfigSource.setCliArgs("--log=file");
|
||||||
|
SmallRyeConfig config2 = createConfig();
|
||||||
|
assertEquals("false", config2.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
|
assertEquals("true", config2.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
|
assertEquals("false", config2.getConfigValue("quarkus.log.syslog.enable").getValue());
|
||||||
|
|
||||||
|
ConfigArgsConfigSource.setCliArgs("--log=console");
|
||||||
|
SmallRyeConfig config3 = createConfig();
|
||||||
|
assertEquals("true", config3.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
|
assertEquals("false", config3.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
|
assertEquals("false", config3.getConfigValue("quarkus.log.syslog.enable").getValue());
|
||||||
|
|
||||||
|
ConfigArgsConfigSource.setCliArgs("--log=console,syslog");
|
||||||
|
SmallRyeConfig config5 = createConfig();
|
||||||
|
assertEquals("true", config5.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
|
assertEquals("false", config5.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
|
assertEquals("true", config5.getConfigValue("quarkus.log.syslog.enable").getValue());
|
||||||
|
|
||||||
|
ConfigArgsConfigSource.setCliArgs("--log=syslog");
|
||||||
|
SmallRyeConfig config6 = createConfig();
|
||||||
|
assertEquals("false", config6.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
|
assertEquals("false", config6.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
|
assertEquals("true", config6.getConfigValue("quarkus.log.syslog.enable").getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void syslogDefaults() {
|
||||||
|
initConfig();
|
||||||
|
|
||||||
|
assertConfig(Map.of(
|
||||||
|
"log-syslog-enabled", "false",
|
||||||
|
"log-syslog-endpoint", "localhost:514",
|
||||||
|
"log-syslog-type", "rfc5424",
|
||||||
|
"log-syslog-app-name", "keycloak",
|
||||||
|
"log-syslog-protocol", "tcp",
|
||||||
|
"log-syslog-format", DEFAULT_LOG_FORMAT,
|
||||||
|
"log-syslog-output", DEFAULT_SYSLOG_OUTPUT.toString()
|
||||||
|
));
|
||||||
|
assertThat(Configuration.getOptionalKcValue(LoggingOptions.LOG_SYSLOG_MAX_LENGTH).orElse(null), CoreMatchers.nullValue());
|
||||||
|
|
||||||
|
assertExternalConfig(Map.of(
|
||||||
|
"quarkus.log.syslog.enable", "false",
|
||||||
|
"quarkus.log.syslog.endpoint", "localhost:514",
|
||||||
|
"quarkus.log.syslog.syslog-type", "rfc5424",
|
||||||
|
"quarkus.log.syslog.app-name", "keycloak",
|
||||||
|
"quarkus.log.syslog.protocol", "tcp",
|
||||||
|
"quarkus.log.syslog.format", DEFAULT_LOG_FORMAT,
|
||||||
|
"quarkus.log.syslog.json", "false"
|
||||||
|
));
|
||||||
|
|
||||||
|
// The default max-length attribute is set in the org.jboss.logmanager.handlers.SyslogHandler if not specified in config
|
||||||
|
assertThat(Configuration.getOptionalValue("quarkus.log.syslog.max-length").orElse(null), CoreMatchers.nullValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void syslogDifferentValues() {
|
||||||
|
putEnvVars(Map.of(
|
||||||
|
"KC_LOG", "syslog",
|
||||||
|
"KC_LOG_SYSLOG_ENDPOINT", "192.168.0.42:515",
|
||||||
|
"KC_LOG_SYSLOG_TYPE", "rfc3164",
|
||||||
|
"KC_LOG_SYSLOG_MAX_LENGTH", "4096",
|
||||||
|
"KC_LOG_SYSLOG_APP_NAME", "keycloak2",
|
||||||
|
"KC_LOG_SYSLOG_PROTOCOL", "udp",
|
||||||
|
"KC_LOG_SYSLOG_FORMAT", "some format",
|
||||||
|
"KC_LOG_SYSLOG_OUTPUT", "json"
|
||||||
|
));
|
||||||
|
|
||||||
|
initConfig();
|
||||||
|
|
||||||
|
assertConfig(Map.of(
|
||||||
|
"log-syslog-enabled", "true",
|
||||||
|
"log-syslog-endpoint", "192.168.0.42:515",
|
||||||
|
"log-syslog-type", "rfc3164",
|
||||||
|
"log-syslog-max-length", "4096",
|
||||||
|
"log-syslog-app-name", "keycloak2",
|
||||||
|
"log-syslog-protocol", "udp",
|
||||||
|
"log-syslog-format", "some format",
|
||||||
|
"log-syslog-output", "json"
|
||||||
|
));
|
||||||
|
|
||||||
|
assertExternalConfig(Map.of(
|
||||||
|
"quarkus.log.syslog.enable", "true",
|
||||||
|
"quarkus.log.syslog.endpoint", "192.168.0.42:515",
|
||||||
|
"quarkus.log.syslog.syslog-type", "rfc3164",
|
||||||
|
"quarkus.log.syslog.max-length", "4096",
|
||||||
|
"quarkus.log.syslog.app-name", "keycloak2",
|
||||||
|
"quarkus.log.syslog.protocol", "udp",
|
||||||
|
"quarkus.log.syslog.format", "some format",
|
||||||
|
"quarkus.log.syslog.json", "true"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void syslogMaxLength() {
|
||||||
|
// RFC3164
|
||||||
|
putEnvVar("KC_LOG_SYSLOG_TYPE", "rfc3164");
|
||||||
|
initConfig();
|
||||||
|
|
||||||
|
assertConfig("log-syslog-type", "rfc3164");
|
||||||
|
assertThat(Configuration.getOptionalKcValue(LoggingOptions.LOG_SYSLOG_MAX_LENGTH).orElse(null), CoreMatchers.nullValue());
|
||||||
|
assertThat(Configuration.getOptionalValue("quarkus.log.syslog.max-length").orElse(null), CoreMatchers.nullValue());
|
||||||
|
|
||||||
|
// RFC5424
|
||||||
|
putEnvVar("KC_LOG_SYSLOG_TYPE", "rfc5424");
|
||||||
|
initConfig();
|
||||||
|
|
||||||
|
assertThat(Configuration.getOptionalKcValue(LoggingOptions.LOG_SYSLOG_MAX_LENGTH).orElse(null), CoreMatchers.nullValue());
|
||||||
|
assertThat(Configuration.getOptionalValue("quarkus.log.syslog.max-length").orElse(null), CoreMatchers.nullValue());
|
||||||
|
|
||||||
|
// Specific max-length
|
||||||
|
removeEnvVar("KC_LOG_SYSLOG_TYPE");
|
||||||
|
putEnvVar("KC_LOG_SYSLOG_MAX_LENGTH", "512");
|
||||||
|
initConfig();
|
||||||
|
|
||||||
|
assertConfig("log-syslog-max-length", "512");
|
||||||
|
assertExternalConfig("quarkus.log.syslog.max-length", "512");
|
||||||
|
}
|
||||||
|
}
|
|
@ -154,25 +154,33 @@ Logging:
|
||||||
categories and their levels. For the root category, you don't need to
|
categories and their levels. For the root category, you don't need to
|
||||||
specify a category. Default: info.
|
specify a category. Default: info.
|
||||||
--log-syslog-app-name <name>
|
--log-syslog-app-name <name>
|
||||||
The app name used when formatting the message in RFC5424 format. Default:
|
Set the app name used when formatting the message in RFC5424 format. Default:
|
||||||
keycloak. Available only when Syslog is activated.
|
keycloak. Available only when Syslog is activated.
|
||||||
--log-syslog-endpoint <host:port>
|
--log-syslog-endpoint <host:port>
|
||||||
The IP address and port of the syslog server. Default: localhost:514.
|
Set the IP address and port of the Syslog server. Default: localhost:514.
|
||||||
Available only when Syslog is activated.
|
Available only when Syslog is activated.
|
||||||
--log-syslog-format <format>
|
--log-syslog-format <format>
|
||||||
Set a format specific to syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
Set a format specific to Syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
||||||
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
||||||
--log-syslog-include-trace <true|false>
|
--log-syslog-include-trace <true|false>
|
||||||
Include tracing information in the syslog. If the 'log-syslog-format' option
|
Include tracing information in the Syslog. If the 'log-syslog-format' option
|
||||||
is specified, this option has no effect. Default: true. Available only when
|
is specified, this option has no effect. Default: true. Available only when
|
||||||
Syslog handler and Tracing is activated.
|
Syslog handler and Tracing 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
|
||||||
|
2048 when 'log-syslog-type' is rfc5424 (default) and 1024 when
|
||||||
|
'log-syslog-type' is rfc3164. Available only when Syslog is activated.
|
||||||
--log-syslog-output <output>
|
--log-syslog-output <output>
|
||||||
Set the syslog output to JSON or default (plain) unstructured logging.
|
Set the Syslog output to JSON or default (plain) unstructured logging.
|
||||||
Possible values are: default, json. Default: default. Available only when
|
Possible values are: default, json. Default: default. Available only when
|
||||||
Syslog is activated.
|
Syslog is activated.
|
||||||
--log-syslog-protocol <protocol>
|
--log-syslog-protocol <protocol>
|
||||||
Sets the protocol used to connect to the syslog server. Possible values are:
|
Set the protocol used to connect to the Syslog server. Possible values are:
|
||||||
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
||||||
|
--log-syslog-type <type>
|
||||||
|
Set the Syslog type used to format the sent message. Possible values are:
|
||||||
|
rfc5424, rfc3164. Default: rfc5424. Available only when Syslog is activated.
|
||||||
|
|
||||||
Tracing (Preview):
|
Tracing (Preview):
|
||||||
|
|
||||||
|
|
|
@ -154,25 +154,33 @@ Logging:
|
||||||
categories and their levels. For the root category, you don't need to
|
categories and their levels. For the root category, you don't need to
|
||||||
specify a category. Default: info.
|
specify a category. Default: info.
|
||||||
--log-syslog-app-name <name>
|
--log-syslog-app-name <name>
|
||||||
The app name used when formatting the message in RFC5424 format. Default:
|
Set the app name used when formatting the message in RFC5424 format. Default:
|
||||||
keycloak. Available only when Syslog is activated.
|
keycloak. Available only when Syslog is activated.
|
||||||
--log-syslog-endpoint <host:port>
|
--log-syslog-endpoint <host:port>
|
||||||
The IP address and port of the syslog server. Default: localhost:514.
|
Set the IP address and port of the Syslog server. Default: localhost:514.
|
||||||
Available only when Syslog is activated.
|
Available only when Syslog is activated.
|
||||||
--log-syslog-format <format>
|
--log-syslog-format <format>
|
||||||
Set a format specific to syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
Set a format specific to Syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
||||||
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
||||||
--log-syslog-include-trace <true|false>
|
--log-syslog-include-trace <true|false>
|
||||||
Include tracing information in the syslog. If the 'log-syslog-format' option
|
Include tracing information in the Syslog. If the 'log-syslog-format' option
|
||||||
is specified, this option has no effect. Default: true. Available only when
|
is specified, this option has no effect. Default: true. Available only when
|
||||||
Syslog handler and Tracing is activated.
|
Syslog handler and Tracing 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
|
||||||
|
2048 when 'log-syslog-type' is rfc5424 (default) and 1024 when
|
||||||
|
'log-syslog-type' is rfc3164. Available only when Syslog is activated.
|
||||||
--log-syslog-output <output>
|
--log-syslog-output <output>
|
||||||
Set the syslog output to JSON or default (plain) unstructured logging.
|
Set the Syslog output to JSON or default (plain) unstructured logging.
|
||||||
Possible values are: default, json. Default: default. Available only when
|
Possible values are: default, json. Default: default. Available only when
|
||||||
Syslog is activated.
|
Syslog is activated.
|
||||||
--log-syslog-protocol <protocol>
|
--log-syslog-protocol <protocol>
|
||||||
Sets the protocol used to connect to the syslog server. Possible values are:
|
Set the protocol used to connect to the Syslog server. Possible values are:
|
||||||
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
||||||
|
--log-syslog-type <type>
|
||||||
|
Set the Syslog type used to format the sent message. Possible values are:
|
||||||
|
rfc5424, rfc3164. Default: rfc5424. Available only when Syslog is activated.
|
||||||
|
|
||||||
Tracing (Preview):
|
Tracing (Preview):
|
||||||
|
|
||||||
|
|
|
@ -330,25 +330,33 @@ Logging:
|
||||||
categories and their levels. For the root category, you don't need to
|
categories and their levels. For the root category, you don't need to
|
||||||
specify a category. Default: info.
|
specify a category. Default: info.
|
||||||
--log-syslog-app-name <name>
|
--log-syslog-app-name <name>
|
||||||
The app name used when formatting the message in RFC5424 format. Default:
|
Set the app name used when formatting the message in RFC5424 format. Default:
|
||||||
keycloak. Available only when Syslog is activated.
|
keycloak. Available only when Syslog is activated.
|
||||||
--log-syslog-endpoint <host:port>
|
--log-syslog-endpoint <host:port>
|
||||||
The IP address and port of the syslog server. Default: localhost:514.
|
Set the IP address and port of the Syslog server. Default: localhost:514.
|
||||||
Available only when Syslog is activated.
|
Available only when Syslog is activated.
|
||||||
--log-syslog-format <format>
|
--log-syslog-format <format>
|
||||||
Set a format specific to syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
Set a format specific to Syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
||||||
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
||||||
--log-syslog-include-trace <true|false>
|
--log-syslog-include-trace <true|false>
|
||||||
Include tracing information in the syslog. If the 'log-syslog-format' option
|
Include tracing information in the Syslog. If the 'log-syslog-format' option
|
||||||
is specified, this option has no effect. Default: true. Available only when
|
is specified, this option has no effect. Default: true. Available only when
|
||||||
Syslog handler and Tracing is activated.
|
Syslog handler and Tracing 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
|
||||||
|
2048 when 'log-syslog-type' is rfc5424 (default) and 1024 when
|
||||||
|
'log-syslog-type' is rfc3164. Available only when Syslog is activated.
|
||||||
--log-syslog-output <output>
|
--log-syslog-output <output>
|
||||||
Set the syslog output to JSON or default (plain) unstructured logging.
|
Set the Syslog output to JSON or default (plain) unstructured logging.
|
||||||
Possible values are: default, json. Default: default. Available only when
|
Possible values are: default, json. Default: default. Available only when
|
||||||
Syslog is activated.
|
Syslog is activated.
|
||||||
--log-syslog-protocol <protocol>
|
--log-syslog-protocol <protocol>
|
||||||
Sets the protocol used to connect to the syslog server. Possible values are:
|
Set the protocol used to connect to the Syslog server. Possible values are:
|
||||||
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
||||||
|
--log-syslog-type <type>
|
||||||
|
Set the Syslog type used to format the sent message. Possible values are:
|
||||||
|
rfc5424, rfc3164. Default: rfc5424. Available only when Syslog is activated.
|
||||||
|
|
||||||
Tracing (Preview):
|
Tracing (Preview):
|
||||||
|
|
||||||
|
|
|
@ -331,25 +331,33 @@ Logging:
|
||||||
categories and their levels. For the root category, you don't need to
|
categories and their levels. For the root category, you don't need to
|
||||||
specify a category. Default: info.
|
specify a category. Default: info.
|
||||||
--log-syslog-app-name <name>
|
--log-syslog-app-name <name>
|
||||||
The app name used when formatting the message in RFC5424 format. Default:
|
Set the app name used when formatting the message in RFC5424 format. Default:
|
||||||
keycloak. Available only when Syslog is activated.
|
keycloak. Available only when Syslog is activated.
|
||||||
--log-syslog-endpoint <host:port>
|
--log-syslog-endpoint <host:port>
|
||||||
The IP address and port of the syslog server. Default: localhost:514.
|
Set the IP address and port of the Syslog server. Default: localhost:514.
|
||||||
Available only when Syslog is activated.
|
Available only when Syslog is activated.
|
||||||
--log-syslog-format <format>
|
--log-syslog-format <format>
|
||||||
Set a format specific to syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
Set a format specific to Syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
||||||
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
||||||
--log-syslog-include-trace <true|false>
|
--log-syslog-include-trace <true|false>
|
||||||
Include tracing information in the syslog. If the 'log-syslog-format' option
|
Include tracing information in the Syslog. If the 'log-syslog-format' option
|
||||||
is specified, this option has no effect. Default: true. Available only when
|
is specified, this option has no effect. Default: true. Available only when
|
||||||
Syslog handler and Tracing is activated.
|
Syslog handler and Tracing 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
|
||||||
|
2048 when 'log-syslog-type' is rfc5424 (default) and 1024 when
|
||||||
|
'log-syslog-type' is rfc3164. Available only when Syslog is activated.
|
||||||
--log-syslog-output <output>
|
--log-syslog-output <output>
|
||||||
Set the syslog output to JSON or default (plain) unstructured logging.
|
Set the Syslog output to JSON or default (plain) unstructured logging.
|
||||||
Possible values are: default, json. Default: default. Available only when
|
Possible values are: default, json. Default: default. Available only when
|
||||||
Syslog is activated.
|
Syslog is activated.
|
||||||
--log-syslog-protocol <protocol>
|
--log-syslog-protocol <protocol>
|
||||||
Sets the protocol used to connect to the syslog server. Possible values are:
|
Set the protocol used to connect to the Syslog server. Possible values are:
|
||||||
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
||||||
|
--log-syslog-type <type>
|
||||||
|
Set the Syslog type used to format the sent message. Possible values are:
|
||||||
|
rfc5424, rfc3164. Default: rfc5424. Available only when Syslog is activated.
|
||||||
|
|
||||||
Tracing (Preview):
|
Tracing (Preview):
|
||||||
|
|
||||||
|
|
|
@ -282,25 +282,33 @@ Logging:
|
||||||
categories and their levels. For the root category, you don't need to
|
categories and their levels. For the root category, you don't need to
|
||||||
specify a category. Default: info.
|
specify a category. Default: info.
|
||||||
--log-syslog-app-name <name>
|
--log-syslog-app-name <name>
|
||||||
The app name used when formatting the message in RFC5424 format. Default:
|
Set the app name used when formatting the message in RFC5424 format. Default:
|
||||||
keycloak. Available only when Syslog is activated.
|
keycloak. Available only when Syslog is activated.
|
||||||
--log-syslog-endpoint <host:port>
|
--log-syslog-endpoint <host:port>
|
||||||
The IP address and port of the syslog server. Default: localhost:514.
|
Set the IP address and port of the Syslog server. Default: localhost:514.
|
||||||
Available only when Syslog is activated.
|
Available only when Syslog is activated.
|
||||||
--log-syslog-format <format>
|
--log-syslog-format <format>
|
||||||
Set a format specific to syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
Set a format specific to Syslog entries. Default: %d{yyyy-MM-dd HH:mm:ss,SSS} %
|
||||||
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
-5p [%c] (%t) %s%e%n. Available only when Syslog is activated.
|
||||||
--log-syslog-include-trace <true|false>
|
--log-syslog-include-trace <true|false>
|
||||||
Include tracing information in the syslog. If the 'log-syslog-format' option
|
Include tracing information in the Syslog. If the 'log-syslog-format' option
|
||||||
is specified, this option has no effect. Default: true. Available only when
|
is specified, this option has no effect. Default: true. Available only when
|
||||||
Syslog handler and Tracing is activated.
|
Syslog handler and Tracing 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
|
||||||
|
2048 when 'log-syslog-type' is rfc5424 (default) and 1024 when
|
||||||
|
'log-syslog-type' is rfc3164. Available only when Syslog is activated.
|
||||||
--log-syslog-output <output>
|
--log-syslog-output <output>
|
||||||
Set the syslog output to JSON or default (plain) unstructured logging.
|
Set the Syslog output to JSON or default (plain) unstructured logging.
|
||||||
Possible values are: default, json. Default: default. Available only when
|
Possible values are: default, json. Default: default. Available only when
|
||||||
Syslog is activated.
|
Syslog is activated.
|
||||||
--log-syslog-protocol <protocol>
|
--log-syslog-protocol <protocol>
|
||||||
Sets the protocol used to connect to the syslog server. Possible values are:
|
Set the protocol used to connect to the Syslog server. Possible values are:
|
||||||
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
tcp, udp, ssl-tcp. Default: tcp. Available only when Syslog is activated.
|
||||||
|
--log-syslog-type <type>
|
||||||
|
Set the Syslog type used to format the sent message. Possible values are:
|
||||||
|
rfc5424, rfc3164. Default: rfc5424. Available only when Syslog is activated.
|
||||||
|
|
||||||
Tracing (Preview):
|
Tracing (Preview):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue