java - Progress bar on console using Log4J or LogBack -


i have console application prints output using log4j. useful can implement switch optionally show debug messages, though hidden default.

this application has long running actions progress bar appropriate.

what best way implement using either log4j or logback?

to write progress bar or sort of updating text console, end output \r (carriage return) instead of \n (new line) next line overwrites it. question goes more detail. f-ansi library enables generate nice-looking console output including overwriting previous line.

but if set on using logging framework, not not possible, it's not want. chrism suggests, right way log progress log new line every percent done far. way, can see both program doing , how far along in context.

what sounds want separate logging program's actual output (this idea, disregarding progress bar issue). use logging framework log information program's execution; things or debugging interested in. actual program's output should written directly stdout via system.out.

you can separately decide want logging. can written stdout, , logs , output can live together, better write stderr (which makes redirecting easier) or log file (which makes program's output cleaner, , persists logs reference later).


also, if java isn't prerequisite pv command provides powerful, customizable progress bar based on amount of data piped through it.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -