This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new b8f45b2569 improve logging levels (#2712)
b8f45b2569 is described below
commit b8f45b2569987a779f0c60b6d6718ba0b94853cf
Author: Tim Allison <[email protected]>
AuthorDate: Mon Mar 23 21:14:02 2026 -0400
improve logging levels (#2712)
---
.../resources/pipes-fork-server-default-log4j2.xml | 2 +-
.../org/apache/tika/async/cli/TikaAsyncCLI.java | 4 ++--
.../tika/pipes/core/PerClientServerManager.java | 14 +++++++++-----
.../org/apache/tika/pipes/core/PipesClient.java | 4 ++--
.../tika/pipes/core/SharedServerManager.java | 4 ++--
.../tika/pipes/core/server/ConnectionHandler.java | 11 ++++++++++-
.../apache/tika/pipes/core/server/EmitHandler.java | 10 +++++-----
.../tika/pipes/core/server/FetchHandler.java | 4 ++--
.../tika/pipes/core/server/ParseHandler.java | 22 +++++++++++-----------
.../apache/tika/pipes/core/server/PipesServer.java | 18 +++++++++++++++++-
.../apache/tika/pipes/core/server/PipesWorker.java | 4 ++--
.../resources/pipes-fork-server-default-log4j2.xml | 2 +-
12 files changed, 64 insertions(+), 35 deletions(-)
diff --git a/tika-core/src/main/resources/pipes-fork-server-default-log4j2.xml
b/tika-core/src/main/resources/pipes-fork-server-default-log4j2.xml
index 5f946e6e5c..9e87d34806 100644
--- a/tika-core/src/main/resources/pipes-fork-server-default-log4j2.xml
+++ b/tika-core/src/main/resources/pipes-fork-server-default-log4j2.xml
@@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
-<Configuration status="INFO">
+<Configuration status="WARN">
<Appenders>
<Console name="console" target="SYSTEM_ERR">
<PatternLayout
diff --git
a/tika-pipes/tika-async-cli/src/main/java/org/apache/tika/async/cli/TikaAsyncCLI.java
b/tika-pipes/tika-async-cli/src/main/java/org/apache/tika/async/cli/TikaAsyncCLI.java
index ddfd583ef9..3f02173a5e 100644
---
a/tika-pipes/tika-async-cli/src/main/java/org/apache/tika/async/cli/TikaAsyncCLI.java
+++
b/tika-pipes/tika-async-cli/src/main/java/org/apache/tika/async/cli/TikaAsyncCLI.java
@@ -95,10 +95,10 @@ public class TikaAsyncCLI {
}
private static void processCommandLine(String[] args) throws Exception {
- LOG.warn("processing args " + args.length);
+ LOG.debug("processing args " + args.length);
if (args.length == 1) {
if (args[0].endsWith(".json")) {
- LOG.warn("processing args");
+ LOG.debug("processing args");
TikaJsonConfig tikaJsonConfig =
TikaJsonConfig.load(Paths.get(args[0]));
Optional<PipesIterator> pipesIteratorOpt =
PipesIteratorManager.load(TikaPluginManager.load(tikaJsonConfig),
tikaJsonConfig);
if (pipesIteratorOpt.isEmpty()) {
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PerClientServerManager.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PerClientServerManager.java
index a8cf40ba10..722f1ba362 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PerClientServerManager.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PerClientServerManager.java
@@ -116,7 +116,11 @@ public class PerClientServerManager implements
ServerManager {
process.waitFor(1, TimeUnit.SECONDS);
if (!process.isAlive()) {
int exitValue = process.exitValue();
- LOG.warn("clientId={}: process exited with code {}",
clientId, exitValue);
+ if (exitValue == 0) {
+ LOG.info("clientId={}: process exited cleanly",
clientId);
+ } else {
+ LOG.warn("clientId={}: process exited with code {}",
clientId, exitValue);
+ }
return exitValue;
} else {
LOG.warn("clientId={}: process still running after crash",
clientId);
@@ -193,7 +197,7 @@ public class PerClientServerManager implements
ServerManager {
serverSocket.bind(new
InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 50);
port = serverSocket.getLocalPort();
- LOG.info("clientId={}: starting server on port={}", clientId, port);
+ LOG.trace("clientId={}: starting server on port={}", clientId, port);
tmpDir = Files.createTempDirectory("pipes-server-" + clientId + "-");
ProcessBuilder pb = new ProcessBuilder(getCommandline());
@@ -341,7 +345,7 @@ public class PerClientServerManager implements
ServerManager {
commandLine.add("-Djava.awt.headless=true");
}
if (hasExitOnOOM) {
- LOG.warn("I notice that you have a jdk setting to exit/crash on
OOM. If you run heavy external processes " +
+ LOG.info("I notice that you have a jdk setting to exit/crash on
OOM. If you run heavy external processes " +
"like tesseract, this setting may result in orphaned
processes which could be disastrous for performance.");
}
if (!hasLog4j) {
@@ -355,7 +359,7 @@ public class PerClientServerManager implements
ServerManager {
commandLine.add(Integer.toString(port));
commandLine.add(tikaConfigPath.toAbsolutePath().toString());
- LOG.info("clientId={}: commandline: {}", clientId, commandLine);
+ LOG.debug("clientId={}: commandline: {}", clientId, commandLine);
return commandLine.toArray(new String[0]);
}
@@ -365,7 +369,7 @@ public class PerClientServerManager implements
ServerManager {
String normalizedClasspath = classpath.replace("\\", "/");
String content = "-cp\n\"" + normalizedClasspath + "\"\n";
Files.writeString(argFile, content, StandardCharsets.UTF_8);
- LOG.info("clientId={}: wrote argfile with classpath ({} chars) to {},
content starts with: {}",
+ LOG.debug("clientId={}: wrote argfile with classpath ({} chars) to {},
content starts with: {}",
clientId, classpath.length(), argFile, content.substring(0,
Math.min(100, content.length())));
return argFile;
}
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PipesClient.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PipesClient.java
index b65a0627b7..be1b1e6034 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PipesClient.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PipesClient.java
@@ -382,7 +382,7 @@ public class PipesClient implements Closeable {
throw new IOException("Unexpected message type from
server: " + msg.type());
}
} catch (SocketTimeoutException e) {
- LOG.warn("clientId={}: Socket timeout exception while waiting
for server", pipesClientId, e);
+ LOG.info("clientId={}: Socket timeout exception while waiting
for server", pipesClientId, e);
// Mark for restart - server is stuck on current request and
needs to be restarted
serverManager.markServerForRestart();
closeConnection();
@@ -431,7 +431,7 @@ public class PipesClient implements Closeable {
private void waitForStartup() throws IOException {
PipesMessage msg = PipesMessage.read(connectionTuple.input);
if (msg.type() == PipesMessageType.READY) {
- LOG.debug("clientId={}: server ready", pipesClientId);
+ LOG.info("clientId={}: server successfully started",
pipesClientId);
} else if (msg.type() == PipesMessageType.STARTUP_FAILED) {
// Send ACK for startup failure
PipesMessage.ack().write(connectionTuple.output);
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/SharedServerManager.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/SharedServerManager.java
index e323dd160e..a28148f684 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/SharedServerManager.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/SharedServerManager.java
@@ -255,7 +255,7 @@ public class SharedServerManager implements ServerManager {
new SecureRandom().nextBytes(token);
currentToken = token;
- LOG.warn("\n\n" +
+ LOG.info("\n\n" +
" __ __ ___ _ ___ \n" +
" \\ \\ / / / _ \\ | | / _ \\ \n" +
" \\ V / | | | | | | | | | |\n" +
@@ -446,7 +446,7 @@ public class SharedServerManager implements ServerManager {
commandLine.add("-Djava.awt.headless=true");
}
if (hasExitOnOOM) {
- LOG.warn("ExitOnOutOfMemoryError/CrashOnOutOfMemoryError is set.
In shared mode, " +
+ LOG.info("ExitOnOutOfMemoryError/CrashOnOutOfMemoryError is set.
In shared mode, " +
"an OOM will kill the shared server, affecting all
clients.");
}
if (!hasLog4j) {
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java
index 8cf84ca064..3162f0922a 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ConnectionHandler.java
@@ -24,6 +24,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.SocketException;
+import java.net.SocketTimeoutException;
import java.time.Duration;
import java.time.Instant;
import java.util.Locale;
@@ -133,7 +134,15 @@ public class ConnectionHandler implements Runnable,
Closeable {
while (running) {
try {
- PipesMessage msg = PipesMessage.read(input);
+ PipesMessage msg;
+ try {
+ msg = PipesMessage.read(input);
+ } catch (SocketTimeoutException e) {
+ // Socket timeout while idle is the normal inactivity
shutdown path.
+ LOG.info("handlerId={}: socket timeout while waiting for
task, closing connection",
+ handlerId);
+ return;
+ }
LOG.trace("handlerId={}: received message type={}", handlerId,
msg.type());
switch (msg.type()) {
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/EmitHandler.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/EmitHandler.java
index 78a21bfa23..aeede97346 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/EmitHandler.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/EmitHandler.java
@@ -107,10 +107,10 @@ class EmitHandler {
emitter = emitterManager.getEmitter(emitKey.getEmitterId());
} catch (org.apache.tika.pipes.api.emitter.EmitterNotFoundException e)
{
String noEmitterMsg = getNoEmitterMsg(taskId);
- LOG.warn(noEmitterMsg);
+ LOG.info(noEmitterMsg);
return new
PipesResult(PipesResult.RESULT_STATUS.EMITTER_NOT_FOUND, noEmitterMsg);
} catch (IOException | TikaException e) {
- LOG.warn("Couldn't initialize emitter for task id '" + taskId +
"'", e);
+ LOG.info("Couldn't initialize emitter for task id '" + taskId +
"'", e);
return new
PipesResult(PipesResult.RESULT_STATUS.EMITTER_INITIALIZATION_EXCEPTION,
ExceptionUtils.getStackTrace(e));
}
try {
@@ -124,7 +124,7 @@ class EmitHandler {
emitter.emit(emitKey.getEmitKey(),
parseData.getMetadataList(), parseContext);
}
} catch (IOException e) {
- LOG.warn("emit exception", e);
+ LOG.info("emit exception", e);
String msg = ExceptionUtils.getStackTrace(e);
//for now, we're hiding the parse exception if there was also an
emit exception
return new PipesResult(PipesResult.RESULT_STATUS.EMIT_EXCEPTION,
msg);
@@ -134,7 +134,7 @@ class EmitHandler {
try {
passbackFilter.filter(parseData.metadataList);
} catch (TikaException e) {
- LOG.warn("problem filtering for pass back", e);
+ LOG.info("problem filtering for pass back", e);
}
if (StringUtils.isBlank(parseExceptionStack)) {
return new
PipesResult(PipesResult.RESULT_STATUS.EMIT_SUCCESS_PASSBACK, new
EmitDataImpl(emitKey.getEmitKey(), parseData.metadataList));
@@ -250,7 +250,7 @@ class EmitHandler {
try {
parseData.filter(filter, parseContext);
} catch (TikaException e) {
- LOG.warn("failed to filter metadata list", e);
+ LOG.info("failed to filter metadata list", e);
}
}
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/FetchHandler.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/FetchHandler.java
index c14ee24656..915ba5b057 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/FetchHandler.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/FetchHandler.java
@@ -60,10 +60,10 @@ class FetchHandler {
return new
FetcherOrResult(fetcherManager.getFetcher(t.getFetchKey().getFetcherId()),
null);
} catch (IllegalArgumentException e) {
String noFetcherMsg =
getNoFetcherMsg(t.getFetchKey().getFetcherId());
- LOG.warn(noFetcherMsg);
+ LOG.info(noFetcherMsg);
return new FetcherOrResult(null, new
PipesResult(PipesResult.RESULT_STATUS.FETCHER_NOT_FOUND, noFetcherMsg));
} catch (IOException | TikaException e) {
- LOG.warn("Couldn't initialize fetcher for fetch id={}", t.getId(),
e);
+ LOG.info("Couldn't initialize fetcher for fetch id={}", t.getId(),
e);
return new FetcherOrResult(null, new
PipesResult(PipesResult.RESULT_STATUS.FETCHER_INITIALIZATION_EXCEPTION,
ExceptionUtils.getStackTrace(e)));
}
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ParseHandler.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ParseHandler.java
index cd02d99767..8916acbafe 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ParseHandler.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/ParseHandler.java
@@ -142,7 +142,7 @@ class ParseHandler {
parseContext.set(SkipContainerDocumentDigest.class,
SkipContainerDocumentDigest.INSTANCE);
} catch (IOException e) {
- LOG.warn("problem digesting: " + t.getId(), e);
+ LOG.info("problem digesting: " + t.getId(), e);
}
}
// Signal to detectors that parsing will follow, so they can prepare
@@ -154,7 +154,7 @@ class ParseHandler {
EmbeddedDocumentUtil.normalizeMediaType(mt.toString()));
metadata.set(TikaCoreProperties.CONTENT_TYPE_PARSER_OVERRIDE,
mt.toString());
} catch (IOException e) {
- LOG.warn("problem detecting: " + t.getId(), e);
+ LOG.info("problem detecting: " + t.getId(), e);
}
UnpackConfig unpackConfig = parseContext.get(UnpackConfig.class);
if (unpackConfig != null &&
@@ -163,7 +163,7 @@ class ParseHandler {
try (InputStream is = Files.newInputStream(tis.getPath())) {
unpackHandler.add(0, metadata, is);
} catch (IOException e) {
- LOG.warn("problem reading source file into embedded document
byte store", e);
+ LOG.info("problem reading source file into embedded document
byte store", e);
}
}
}
@@ -201,14 +201,14 @@ class ParseHandler {
try {
recursiveParserWrapper.parse(stream, handler, metadata,
parseContext);
} catch (SAXException e) {
- LOG.warn("sax problem:" + fetchEmitTuple.getId(), e);
+ LOG.info("sax problem:" + fetchEmitTuple.getId(), e);
} catch (EncryptedDocumentException e) {
- LOG.warn("encrypted document:" + fetchEmitTuple.getId(), e);
+ LOG.info("encrypted document:" + fetchEmitTuple.getId(), e);
} catch (SecurityException e) {
- LOG.warn("security exception:" + fetchEmitTuple.getId(), e);
+ LOG.info("security exception:" + fetchEmitTuple.getId(), e);
throw e;
} catch (Exception e) {
- LOG.warn("parse exception: " + fetchEmitTuple.getId(), e);
+ LOG.info("parse exception: " + fetchEmitTuple.getId(), e);
} finally {
if (LOG.isTraceEnabled()) {
LOG.trace("timer -- parse only time: {} ms",
System.currentTimeMillis() - start);
@@ -242,19 +242,19 @@ class ParseHandler {
autoDetectParser.parse(stream, handler, metadata, parseContext);
} catch (SAXException e) {
containerException = ExceptionUtils.getStackTrace(e);
- LOG.warn("sax problem:" + fetchEmitTuple.getId(), e);
+ LOG.info("sax problem:" + fetchEmitTuple.getId(), e);
if (WriteLimitReachedException.isWriteLimitReached(e)) {
writeLimitReached = true;
}
} catch (EncryptedDocumentException e) {
containerException = ExceptionUtils.getStackTrace(e);
- LOG.warn("encrypted document:" + fetchEmitTuple.getId(), e);
+ LOG.info("encrypted document:" + fetchEmitTuple.getId(), e);
} catch (SecurityException e) {
- LOG.warn("security exception:" + fetchEmitTuple.getId(), e);
+ LOG.info("security exception:" + fetchEmitTuple.getId(), e);
throw e;
} catch (Exception e) {
containerException = ExceptionUtils.getStackTrace(e);
- LOG.warn("parse exception: " + fetchEmitTuple.getId(), e);
+ LOG.info("parse exception: " + fetchEmitTuple.getId(), e);
} finally {
metadata.add(TikaCoreProperties.TIKA_CONTENT, handler.toString());
metadata.set(TikaCoreProperties.TIKA_CONTENT_HANDLER_TYPE,
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java
index e2b9e3b7fa..dc214514be 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketTimeoutException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -319,7 +320,22 @@ public class PipesServer implements AutoCloseable {
//main loop
try {
while (true) {
- PipesMessage msg = PipesMessage.read(input);
+ PipesMessage msg;
+ try {
+ msg = PipesMessage.read(input);
+ } catch (SocketTimeoutException e) {
+ // Socket timeout while idle is the normal inactivity
shutdown path.
+ // Exit cleanly — PipesClient will restart the server if
needed.
+ LOG.info("pipesClientId={}: socket timeout while waiting
for task, shutting down",
+ pipesClientId);
+ try {
+ close();
+ } catch (Exception ex) {
+ //swallow
+ }
+ System.exit(0);
+ return; // unreachable, but needed for compilation
+ }
LOG.trace("pipesClientId={}: received message type={}",
pipesClientId, msg.type());
switch (msg.type()) {
diff --git
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesWorker.java
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesWorker.java
index 141989b27d..136853e5d2 100644
---
a/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesWorker.java
+++
b/tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesWorker.java
@@ -560,7 +560,7 @@ class PipesWorker implements Callable<PipesResult> {
try {
localContext = setupParseContext();
} catch (IOException e) {
- LOG.warn("fetcher initialization exception id={}",
fetchEmitTuple.getId(), e);
+ LOG.info("fetcher initialization exception id={}",
fetchEmitTuple.getId(), e);
return new ParseDataOrPipesResult(null,
new
PipesResult(PipesResult.RESULT_STATUS.FETCHER_INITIALIZATION_EXCEPTION,
ExceptionUtils.getStackTrace(e)));
}
@@ -587,7 +587,7 @@ class PipesWorker implements Callable<PipesResult> {
LOG.error("security exception id={}", fetchEmitTuple.getId(), e);
throw e;
} catch (TikaException | IOException e) {
- LOG.warn("fetch exception id={}", fetchEmitTuple.getId(), e);
+ LOG.info("fetch exception id={}", fetchEmitTuple.getId(), e);
return new ParseDataOrPipesResult(null,
new
PipesResult(PipesResult.RESULT_STATUS.UNSPECIFIED_CRASH,
ExceptionUtils.getStackTrace(e)));
}
diff --git
a/tika-pipes/tika-pipes-core/src/main/resources/pipes-fork-server-default-log4j2.xml
b/tika-pipes/tika-pipes-core/src/main/resources/pipes-fork-server-default-log4j2.xml
index 5f946e6e5c..9e87d34806 100644
---
a/tika-pipes/tika-pipes-core/src/main/resources/pipes-fork-server-default-log4j2.xml
+++
b/tika-pipes/tika-pipes-core/src/main/resources/pipes-fork-server-default-log4j2.xml
@@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
-<Configuration status="INFO">
+<Configuration status="WARN">
<Appenders>
<Console name="console" target="SYSTEM_ERR">
<PatternLayout