Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback: log progress to a single line

I have an application that takes some time to perform an upgrade taks. Support engineers can follow the progress by looking an the log-file regularly. This is a low-tech solution, but this works for our support team.

They will see something like this in the log file:

2013-10-22 - Upgrade progress: x

After 10 seconds, the same line is now: (not a new line)

2013-10-22 - Upgrade progress: xxx

After the upgrade:

2013-10-22 - Upgrade progress: xxxxxxxxxxxxxxxxxxx - Finished

Is this possible with logback?

like image 443
Dimitri Dewaele Avatar asked Feb 25 '26 05:02

Dimitri Dewaele


1 Answers

To be frank, I'm not clear what the value of modifying a log entry would be. I'd image it would be far more useful to support engineers to have a running log of progress percent at point in time.

E.g.:

2014-01-01 10:10:10 - INFO - Upgrade progress: 1%
2014-01-01 10:10:15 - INFO - Upgrade progress: 5%
2014-01-01 10:10:20 - WARN - Upgrade encountered missed dependency, correcting
2014-01-01 10:10:21 - INFO - Upgrade dependency resolved
2014-01-01 10:10:25 - INFO - Upgrade progress: 10%
...
2014-01-01 10:12:51 - INFO - Upgrade progress: 100% - Finished

That way, a support engineer gets both useful indications of current progress, AND that progress will be blended with important notices or other indications of the actual work that the process is doing.

As for the specific question at hand, I don't know of a way to do that without seriously tweaking how logback functions -- it's meant to create a running log of appended entries, not modify existing ones. That runs quite entirely against the grain of logback, or any append-based logging framework.

like image 98
ProgrammerDan Avatar answered Feb 26 '26 18:02

ProgrammerDan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!