Sorry, I think my question was misunderstood.
 
I would like to have the application do the output of the progress bar, 
unfortunately log4j seems to replace the standard system.out and system.err. 
This prevents me from being able to just output text on the same line etc. Do 
you have suggestions on how to still perform direct output (without newlines)?

________________________________

From: Blok, Eelke [mailto:[EMAIL PROTECTED]
Sent: Tue 3/27/2007 11:35 PM
To: Log4J Users List
Subject: RE: log4j and console progress bars



Hi Daren,

It may be possible to get log4j to do this, but it would most definitely
be *more* work than getting your own code to work, because you'd need a
special appender that would actually employ code very similar to what
your own code would have to do. Unless someone has created such an
appender already.

I would say what you're trying to do is really outside the scope of
log4j. Log4j is all about storing information about events that occurred
inside an application; when they happened, what happened, what the
severity is, etc. It doesn't make any assumptions about how to store
events, i.e. they could be "stored" by printing them on screen, writing
them to a text file, inserting them into a database, etc.

What you are talking about is screen presentation, and although the
default log4j distribution can be used to generate screen output, that's
really only inherent to choosing a particular method of storing events,
i.e. writing events to the screen. The default appender that writes to
the screen does so by simply formatting an event into an individual line
and dumping it to the screen.

Hence the need (?) for a special appender, that receives events that
have the percentage in their log message, interprets that message, and
generates the screen output. It may have its purposes when you
anticipate wanting to log the progress in a different manner as well.
However, I think this would be rather backwards and it would make more
sense to just generate the "progress bar" from your application directly
and do any logging that you want to do in *addition* to that, not as the
basis of your user interface. Anyway, it's a moot point, because
whichever route you take, you'll still going to have to figure out how
to generate that progress bar yourself (I'm sure a quick Google will go
a long way in providing the answer).

Good luck,

Eelke
-----Original Message-----
From: Desjardins, Daren [mailto:[EMAIL PROTECTED]
Sent: woensdag 28 maart 2007 3:51
To: [email protected]
Subject: log4j and console progress bars

I have been trying to find how to configure log4j such that a console
app can print out a progress bar as a long running task progresses.
Ideally it would be something of the form "Progress: 12%" and percentage
would increment on the same line, not printing a new line for every
increment.



Unfortunately I have not been able to find out how to make it so I can
write directly to the console (system.in or system.err is fine) without
performing a newline to get it to flush.



Has anyone else tried to perform something similar?



My current example is of the form:



For(..)

{

            Percentage++;

            System.err.print("Progress:" + percentage + "\b\b");

            System.err.flush();

}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to