# Filtering Process Output With tee

DevFeed: [Filtering Process Output With tee](<https://devfeed.tech/articles/filtering-process-output-with-tee-18818.md>)

Original publisher: [Read original article](<https://www.morling.dev/blog/filtering-process-output-with-tee/>)

Published: 2024-02-10T10:11:00Z

Content type: tutorial

Language: en

Sources: [Gunnar Morling](<https://devfeed.tech/sources/gunnar-morling.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [Kubernetes](<https://devfeed.tech/topics/kubernetes.md>), [Logging](<https://devfeed.tech/topics/logging.md>), [Streams](<https://devfeed.tech/topics/streams.md>)

Tags: [capture](<https://devfeed.tech/tags/capture.md>), [disk-space](<https://devfeed.tech/tags/disk-space.md>), [files](<https://devfeed.tech/tags/files.md>), [filter](<https://devfeed.tech/tags/filter.md>), [java](<https://devfeed.tech/tags/java.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [kubernetes](<https://devfeed.tech/tags/kubernetes.md>), [logging](<https://devfeed.tech/tags/logging.md>), [redirection](<https://devfeed.tech/tags/redirection.md>)

## AI overview

This tutorial explains how to use tee and process substitution to expose complete Java process output to Kubernetes logging while writing only filtered lines to a log file. It also discusses preventing unbounded log growth and illustrates how process substitution uses file descriptors and pipes.

## Source excerpt

Recently I ran into a situation where it was necessary to capture the output of a Java process on the stdout stream, and at the same time a filtered subset of the output in a log file. The former, so that the output gets picked up by the Kubernetes logging infrastructure. The letter for further processing on our end: we were looking to detect when the JVM stops due to an OutOfMemoryError, passing on that information to some error classifier.