aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client-cli
diff options
context:
space:
mode:
Diffstat (limited to 'vespa-feed-client-cli')
-rw-r--r--vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java11
-rw-r--r--vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliClient.java13
-rw-r--r--vespa-feed-client-cli/src/main/resources/logging.properties2
-rw-r--r--vespa-feed-client-cli/src/test/resources/help.txt6
4 files changed, 30 insertions, 2 deletions
diff --git a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
index 35faa89388b..b365446db6d 100644
--- a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
+++ b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
@@ -61,6 +61,7 @@ class CliArguments {
private static final String DOOM_OPTION = "max-failure-seconds";
private static final String PROXY_OPTION = "proxy";
private static final String COMPRESSION = "compression";
+ private static final String LOG_CONFIG_OPTION = "log-config";
private final CommandLine arguments;
@@ -205,6 +206,8 @@ class CliArguments {
}
}
+ Optional<Path> logConfigFile() throws CliArgumentsException { return fileValue(LOG_CONFIG_OPTION); }
+
private OptionalInt intValue(String option) throws CliArgumentsException {
try {
Number number = (Number) arguments.getParsedOptionValue(option);
@@ -373,6 +376,14 @@ class CliArguments {
"Valid arguments are: 'auto' (default), 'none', 'gzip'")
.hasArg()
.type(Compression.class)
+ .build())
+ .addOption(Option.builder()
+ .longOpt(LOG_CONFIG_OPTION)
+ .desc("Specify a path to a Java Util Logging properties file. " +
+ "Overrides the default configuration from " +
+ "VESPA_HOME/conf/vespa-feed-client/logging.properties")
+ .hasArg()
+ .type(File.class)
.build());
}
diff --git a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliClient.java b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliClient.java
index 8f2a5b4c5a0..9037b453e47 100644
--- a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliClient.java
+++ b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliClient.java
@@ -14,6 +14,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -33,6 +34,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BooleanSupplier;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
import java.util.stream.IntStream;
import static java.util.stream.Collectors.joining;
@@ -44,6 +47,7 @@ import static java.util.stream.Collectors.joining;
*/
public class CliClient {
+ private static final Logger log = Logger.getLogger(CliClient.class.getName());
private static final JsonFactory factory = new JsonFactory().disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
private final PrintStream systemOut;
@@ -67,7 +71,16 @@ public class CliClient {
boolean verbose = false;
try {
CliArguments cliArgs = CliArguments.fromRawArgs(rawArgs);
+ var logConfigFile = cliArgs.logConfigFile().orElse(null);
verbose = cliArgs.verboseSpecified();
+ if (logConfigFile != null) {
+ try (InputStream in = new BufferedInputStream(Files.newInputStream(logConfigFile))) {
+ LogManager.getLogManager().readConfiguration(in);
+ log.fine(() -> "Log configuration overridden by " + logConfigFile);
+ } catch (IOException e) {
+ return handleException(verbose, "Failed to read log configuration from " + logConfigFile, e);
+ }
+ }
if (cliArgs.helpSpecified()) {
cliArgs.printHelp(systemOut);
return 0;
diff --git a/vespa-feed-client-cli/src/main/resources/logging.properties b/vespa-feed-client-cli/src/main/resources/logging.properties
index 3f0e8b24e78..e69de29bb2d 100644
--- a/vespa-feed-client-cli/src/main/resources/logging.properties
+++ b/vespa-feed-client-cli/src/main/resources/logging.properties
@@ -1,2 +0,0 @@
-# Disable verbose info logging from org.apache.hc.client5.http.impl.async.AsyncHttpRequestRetryExec
-org.apache.hc.client5.http.impl.async.level = WARNING
diff --git a/vespa-feed-client-cli/src/test/resources/help.txt b/vespa-feed-client-cli/src/test/resources/help.txt
index 554c42af3dc..8e34c61c0f2 100644
--- a/vespa-feed-client-cli/src/test/resources/help.txt
+++ b/vespa-feed-client-cli/src/test/resources/help.txt
@@ -23,6 +23,12 @@ Vespa feed client
--header <arg> HTTP header on the form 'Name:
value'
--help
+ --log-config <arg> Specify a path to a Java Util
+ Logging properties file.
+ Overrides the default
+ configuration from
+ VESPA_HOME/conf/vespa-feed-clien
+ t/logging.properties
--max-failure-seconds <arg> Exit if specified number of
seconds ever pass without any
successful operations. Disabled