This is an automated email from the ASF dual-hosted git repository. tballison pushed a commit to branch TIKA-4809-stage-5 in repository https://gitbox.apache.org/repos/asf/tika.git
commit 55a0943ac73be5e08e4f660013d93f013fa60284 Author: tallison <[email protected]> AuthorDate: Mon Aug 10 07:34:31 2026 -0400 TIKA-4809: Rename logLevel, drop the no-op -a flag, fix --help exit, delete orphan config --- .../ROOT/pages/using-tika/server/index.adoc | 7 +-- .../org/apache/tika/server/core/TikaServerCli.java | 4 +- .../apache/tika/server/core/TikaServerConfig.java | 19 ++++---- .../apache/tika/server/core/TikaServerProcess.java | 19 ++------ .../main/resources/tika-server-config-default.xml | 55 ---------------------- 5 files changed, 18 insertions(+), 86 deletions(-) diff --git a/docs/modules/ROOT/pages/using-tika/server/index.adoc b/docs/modules/ROOT/pages/using-tika/server/index.adoc index 231ded3072..3946c91381 100644 --- a/docs/modules/ROOT/pages/using-tika/server/index.adoc +++ b/docs/modules/ROOT/pages/using-tika/server/index.adoc @@ -92,11 +92,8 @@ The server starts on `localhost:9998` by default. |`-c <file>` or `--config <file>` |Path to `tika-config.json`. See <<_configuration,Configuration>> below. -|`-a <file>` or `--pluginsConfig <file>` -|Path to the Tika Pipes plugins configuration file. - |`-i <id>` or `--id <id>` -|Server ID, surfaced in the `/status` endpoint and in logs. +|Server ID, written to the startup log. Defaults to a random UUID. |`-?` or `--help` |Print the usage message. @@ -182,7 +179,7 @@ curl -T document.pdf http://localhost:9998/meta/Content-Type # single field === Other endpoints * `/version` — server version -* `/status` — health/status (includes server ID) +* `/status` — health/status: state, active task count, files processed * `/parsers` and `/parsers/details` — registered parsers * `/detectors` — registered detectors * `/mime-types` — known MIME types diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerCli.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerCli.java index 9adaa48dd0..b4e89676e9 100644 --- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerCli.java +++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerCli.java @@ -43,8 +43,6 @@ public class TikaServerCli { "listen port (default = 9998)\n"); options.addOption("?", "help", false, "this help message"); options.addOption("c", "config", true, "tika-config file"); - options.addOption("a", "pluginsConfig", true, "tike pipes config"); - options.addOption("i", "id", true, "id to use for server in" + " the server status endpoint and logging"); return options; } @@ -69,7 +67,7 @@ public class TikaServerCli { private static void usage(Options options) throws IOException { HelpFormatter helpFormatter = HelpFormatter.builder().get(); helpFormatter.printHelp("tikaserver", null, options, null, true); - System.exit(-1); + System.exit(0); } } diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java index 8c924e2ce3..f17dbaa0e4 100644 --- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java +++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java @@ -39,7 +39,6 @@ public class TikaServerConfig { public static final int DEFAULT_PORT = 9998; public static final String DEFAULT_HOST = "localhost"; - public static final Set<String> LOG_LEVELS = new HashSet<>(Arrays.asList("debug", "info")); private static final Logger LOG = LoggerFactory.getLogger(TikaServerConfig.class); /** * Endpoints that expose the pipes/fetch machinery (process-isolated pipes @@ -75,8 +74,7 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI .toString(); private int port = DEFAULT_PORT; private String host = DEFAULT_HOST; - //debug or info only - private String logLevel = ""; + private String requestLogLevel = ""; private Path configPath; private ArrayList<String> endpoints = new ArrayList<>(); @@ -93,7 +91,6 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI TikaServerConfig config = null; Set<String> settings = new HashSet<>(); - Path pluginsConfig = null; if (commandLine.hasOption("c")) { config = load(Paths.get(commandLine.getOptionValue("c")), commandLine, settings); @@ -201,15 +198,19 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI this.host = host; } - public String getLogLevel() { - return logLevel; + /** + * Severity at which each request URI is logged. Empty (the default) disables + * request logging entirely; this does not change the log level of anything else. + */ + public String getRequestLogLevel() { + return requestLogLevel; } - public void setLogLevel(String level) throws TikaConfigException { + public void setRequestLogLevel(String level) throws TikaConfigException { if (level.equals("debug") || level.equals("info")) { - this.logLevel = level; + this.requestLogLevel = level; } else { - throw new TikaConfigException("log level must be one of: 'debug' or 'info'"); + throw new TikaConfigException("requestLogLevel must be one of: 'debug' or 'info'"); } } diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java index 0e1c45b3a2..95b98de5d4 100644 --- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java +++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java @@ -22,14 +22,11 @@ import java.nio.file.Files; import java.nio.file.Path; import java.security.GeneralSecurityException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; @@ -100,7 +97,6 @@ import org.apache.tika.utils.StringUtils; public class TikaServerProcess { - public static final Set<String> LOG_LEVELS = new HashSet<>(Arrays.asList("debug", "info")); public static final int BIND_EXCEPTION = 42; private static final Logger LOG = LoggerFactory.getLogger(TikaServerProcess.class); public static int DO_NOT_RESTART_EXIT_VALUE = -100; @@ -110,7 +106,6 @@ public class TikaServerProcess { options.addOption("h", "host", true, "host name, use * for all)"); options.addOption("p", "port", true, "listen port"); options.addOption("c", "config", true, "Tika Configuration xml file to override default config with."); - options.addOption("a", "pluginsConfig", true, "Tika Configuration json for pluginscomponents"); options.addOption("i", "id", true, "id to use for server in server status endpoint"); options.addOption("?", "help", false, "this help message"); return options; @@ -316,16 +311,12 @@ public class TikaServerProcess { // Add ConfigEndpointSecurityFilter to gate /config endpoints writers.add(new ConfigEndpointSecurityFilter(tikaServerConfig.isAllowPerRequestConfig())); + // setRequestLogLevel rejects anything but debug/info, so no validation needed here. TikaLoggingFilter logFilter = null; - if (!StringUtils.isBlank(tikaServerConfig.getLogLevel())) { - String logLevel = tikaServerConfig.getLogLevel(); - if (LOG_LEVELS.contains(logLevel)) { - boolean isInfoLevel = "info".equals(logLevel); - logFilter = new TikaLoggingFilter(isInfoLevel); - writers.add(logFilter); - } else { - LOG.warn("Unsupported request URI log level: {}", logLevel); - } + String requestLogLevel = tikaServerConfig.getRequestLogLevel(); + if (!StringUtils.isBlank(requestLogLevel)) { + logFilter = new TikaLoggingFilter("info".equals(requestLogLevel)); + writers.add(logFilter); } CrossOriginResourceSharingFilter corsFilter = null; diff --git a/tika-server/tika-server-core/src/main/resources/tika-server-config-default.xml b/tika-server/tika-server-core/src/main/resources/tika-server-config-default.xml deleted file mode 100644 index ce8fca1962..0000000000 --- a/tika-server/tika-server-core/src/main/resources/tika-server-config-default.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. ---> -<properties> - <server> - <!-- as of Tika 2.7.0, we do not require the params element here --> - <params> - <!-- which port to start the server on. --> - <port>9998</port> - <host>localhost</host> - <!-- if specified, this will be the id that is used in the - /status endpoint and elsewhere. If an id is specified - and more than one forked processes are invoked, each process - will have an id followed by the port, e.g my_id-9998. If a - forked server has to restart, it will maintain its original id. - If not specified, a UUID will be generated. - --> - <id>my-id</id> - <!-- Origin URL for cors requests. Set to '*' if you - want to allow all CORS requests. Leave blank or remove element - if you do not want to enable CORS. --> - <cors></cors> - <!-- which digests to calculate, comma delimited (e.g. md5,sha256); - optionally specify encoding followed by a colon (e.g. "sha1:32"). - Can be empty if you don't want to calculate a digest --> - <digest>sha256</digest> - <!-- how much to read to memory during the digest phase before - spooling to disc...only if digest is selected --> - <digestMarkLimit>1000000</digestMarkLimit> - <!-- request URI log level 'debug' or 'info'; to change the general log level, - edit the "log4j2.xml" file. --> - <logLevel>info</logLevel> - <!-- whether or not to include the stacktrace when a parse exception happens - in the data returned to the user --> - <returnStackTrace>false</returnStackTrace> - <!-- Per-document process isolation, crash restart, and timeouts are - configured via the pipes section (pipes.forkedJvmArgs, - pipes.numClients) and parse-context.timeout-limits, not here. --> - </params> - </server> -</properties>
