Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7401155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:23:36+00:00 2026-05-29T04:23:36+00:00

I have some pretty simple Java code in which I’m starting another process and

  • 0

I have some pretty simple Java code in which I’m starting another process and attempting to log all standard out and standard error to SLF4J.

this.service.serverProcess = Runtime.getRuntime().exec(arguments);

this.service.serverIsRunning = true;

BufferedReader serverStdout = new BufferedReader(new InputStreamReader(
                    this.service.serverProcess.getInputStream()), 16);
BufferedReader serverStderr = new BufferedReader(new InputStreamReader(
                    this.service.serverProcess.getErrorStream()), 16);

String stdoutLine = null;
String stderrLine = null;

while ((stdoutLine = serverStdout.readLine()) != null || 
        ((stderrLine = serverStderr.readLine()) != null)) {
    if (stdoutLine != null && stdoutLine.trim().length() > 0)
        logger.info("{}", stdoutLine);
    if (stderrLine != null && stderrLine.trim().length() > 0)
        logger.error("{}", stderrLine);
}

try { this.service.serverProcess.waitFor(); } catch (InterruptedException e) {};

this.service.serverIsRunning = false;

Unfortunately, I’m only getting the very first line of output from my process, I never see any more output than that, though I’m sure that there is much more output than what I’m seeing.

What’s going wrong here? I’d like it to log just about as soon as the event happens, as the output is important to the logs I’m keeping. How can I get the full output of STDOUT and STDERR of my Process?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:23:37+00:00Added an answer on May 29, 2026 at 4:23 am

    I suspect the problem is that you’re never reading from stderr – so if the process has filled up whatever buffer it has for stderr but hasn’t printed anything to stdout, you’ll be blocking trying to read stdout.

    I suggest you start one of the reading loops in a different thread: one reads from stdout and one reads from stderr.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple UIScrollView defined inside Interface Builder. I've pasted in some
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out
I'm looking at building a Rails application which will have some pretty large tables
Pretty much what the title says really. We have some code that is .NET
I have some ASP.NET web services which all share a common helper class they
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I've written a pretty simple recursive-descent parser in Java, but having some issues with
I'm doing some relatively simple I/O in Java. I have a .txt files that
I have written some code in java that will guess a number based on
I have been doing some research on test driven development and find it pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.