java - Log4j hanging my application -


im trying console output external application in application. when call externall app code hangs message:

configuring logging...

configuring log4j from: c:\gpat\log4j.cfg

and nothing happens. searched through internet , seems might thread issue. cant modify external application , must go through log4j. read external app this:

stringbuffer output = new stringbuffer();

    try {         runtime rt = runtime.getruntime();         process proc = rt.exec(gsatcommand);         bufferedreader input = new bufferedreader(new inputstreamreader(proc.getinputstream()));         system.out.println("test running...");         string line = null;         while ((line = input.readline()) != null) {             system.out.println(line);   // writes test output console             output.append(line);  output.append("\n");         }         int exitval = proc.waitfor();         system.out.println("process exitvalue: " + exitval);         system.out.println("test executed");     } catch (throwable t) {         t.printstacktrace();     } 

thanks reading.

you need consume both stdout , stderr spawned process in separate threads, prevent blocking behaviour (your spawned process write buffers, , block if buffers aren't being emptied consuming process).

see 2nd paragraph of this answer more details , link suitable fix.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -