this means that if you want to have a progress bar on the console you should 
remove the console appender from your log4j configuration. of course this also 
means that *none* of your logging is shown on the console.
but you could still log into a file.

btw: in my personal opinion writing to system.out is only acceptable for 
console applications and for those apps i think console appender should either 
be set to at least warning level or completely disabled. but this is just 
personal preference.

> -----Ursprüngliche Nachricht-----
> Von: James Stauffer [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 28. März 2007 19:14
> An: Log4J Users List
> Betreff: Re: log4j and console progress bars
> 
> 
> log4j doesn't replace the standard System.out and System.err.  Are you
> running in an app server?  If you use ConsoleAppender then log4j will
> write to System.out which may interfer with your output (by putting
> ouput in the middle of your output).
> 
> On 3/28/07, Desjardins, Daren <[EMAIL PROTECTED]> wrote:
> > 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: log4j-user@logging.apache.org
> > 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]
> >
> >
> 
> 
> -- 
> James Stauffer        http://www.geocities.com/stauffer_james/
> Are you good? Take the test at http://www.livingwaters.com/good/
> 
> ---------------------------------------------------------------------
> 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