Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!rt.uk.eu.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Tue, 31 Jan 2012 03:50:19 -0600 Date: Tue, 31 Jan 2012 09:50:18 +0000 From: bugbear User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.19) Gecko/20110429 Fedora/2.0.14-1.fc13 SeaMonkey/2.0.14 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: how to read back the lines printed out to the console? References: <99599fa8-013c-4132-ac9e-5987d9d5588e@o13g2000vbf.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 42 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-oZSZR48px8yp1URnI5CBABvsq/RYfGmDm5VhmdJ08fiUkDjCvXpJficgxFpfG1UYpWWZDJTmBlxaLpM!8YzdItQN7f0YRNaa9mj3RAwAobo4law8mQM6QaPY6pdcJpfgJKgnKOdUHpu3HHKQvKQZ2d4QsWiT!kSJ94WTBJNQxvAbEhq95irRK8g== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3127 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11674 frame wrote: > Thank you very much for all the replies. Probably I didn't explain my > question clear. After reading all the replies, I am sorry I still > didn't get the idea to proceed. > > My problem is such: our finished Java program has many printing > statements, e.g. > > System.out.println("step A: everything is ok"); > ... > System.out.println("step B: computation starts now"); > ... > > if(so) > { > System.out.println("warning: temperature is too hot"); > } > > There are about 500 of those. When we run the program, all these > messages show up on the console -- that's good. But now, we also want > to keep those messages in a file. I have two ideas, but none of them > is acceptable: > > 1)at the beginning of the program, I added a little piece of code(re- > direct the System output to a file), now all the existing 500 > System.out.println(..) prints to a file, not the console any more -- > this is not good, because the program runs up to 5 hours, we hope to > see the message progressively on the console. With this approach, we > have to wait till the program finished and open the text file to read. > 2)another approach, use log4j to replace those 500 printing statements > -- we are not ready for this approach right now, because there are 500 > of them -- in many classes. log4j has different levels(INFO, WARNING, > ERROR etc). We need to analyze every printing case to decide its > level. It is a too big approach for now. Since ALL your messages come out at one level at the moment, you can assign an arbitrary level (say INFO) in Log4j, and have the same level of control you currently have (none), and fulfil your "file" requirment. Refining the Log4j levels can be deferred indefinitely, according to business requirments. BugBear