To write a progress bar or any update text to the console, simply complete the output with \r (carriage return) instead of \n (new line) so that the next line overwrites it. This issue is discussed in more detail. The F-ANSI library makes it easy to create nice console output, including overwriting the previous line.
But if you are configured to use the registration framework, this is not only not possible, but also not what you want. As ChrisM suggests, the right way to record progress is to register a new line so often with the percentage made so far. Thus, you can see what your program does and how far it is in context.
It seems that you want to do this, to separate your logging from the actual output of your program (this is usually a good idea, even if you do not take into account the problem with the progress bar). Use your logging structure to record information about program execution; things that you or someone is debugging. The actual output of the program should be written directly to stdout through System.out .
You can then decide separately what you want to do with logging. It can also be written to stdout , and your logs and output can live together, but it would be better to write to stderr (which simplifies redirection) or to a log file (which makes your program cleaner and saves your logs for reference later).
Also, if Java is not a prerequisite, the pv command provides a powerful custom progress bar based on the amount of data laid through it.
source share