How to continue recording on one line in Java?

This is similar to this bash file related question .

We created a log that is displayed on the console while we test TestNG:

private Log log = LogFactory.getLog(xyz.class);

Later, during the tests, the journal is filled with details to tell us exactly what is being done:

log.info("Setting browser...");
this.browser = browser;
log.info("Completed.");

Now it prints, as you would expect:

Setting browser...
Completed.

I would like to print this listing on the same line:

Setting browser...

and a few milliseconds later:

Setting browser...Completed.

Is this possible with LogFactory?

+5
source share
2 answers

Not knowing what kind of logging library you are using, I would suggest that the answer will almost certainly not be if you do not want to explicitly specify a newline character everywhere.

java.util.logging ( Log4J) . , . , Log4J.

 %-5p [%t]: %m%n

, , %m (%n - , ; %t %p , ), .

, :

log.info("I want this on one line\n");
+5

. , , -.

, . . Setting browswer.. , completed - .

+2

All Articles