Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   log4j messages out of order w.r.t JUnit under Ant? (http://www.velocityreviews.com/forums/t130532-log4j-messages-out-of-order-w-r-t-junit-under-ant.html)

bugbear 01-20-2004 12:00 PM

log4j messages out of order w.r.t JUnit under Ant?
 
Being a conventional sort of soul, I'm using
Ant as my build tool, Log4j as my logging tool
and JUnit as my test harness.

When a JUnit test fails unexpectedly (typically
with an Exception), I would like to enable
some logging, to see the events and actions
that build up to the problem, allowing
rapid (hah!) diagnosis and fixing.

But the messages from Log4J are not
merged nicely with the messages from JUnit
in the output files.

It looks like some kind of buffering problem,
a bit like you get when you capture both
stdout and stderr to the same file under *nix.

Can anyone help?

BugBear

Chris 01-20-2004 04:14 PM

Re: log4j messages out of order w.r.t JUnit under Ant?
 
Your assumption is correct.

I don't know if there is any way or stopping Log4J / Junit
inter-leaving their output (or any other combo of output streams for
that matter).

I'd suggest sending your log output to a file instead (presumably you
only need to look at it if one of your tests fails anyway?)

- sarge

bugbear 01-21-2004 09:52 AM

Re: log4j messages out of order w.r.t JUnit under Ant?
 
sarge_chris@hotmail.com (Chris) wrote in message news:<568394b1.0401200814.29fbe22b@posting.google. com>...
> Your assumption is correct.
>
> I don't know if there is any way or stopping Log4J / Junit
> inter-leaving their output (or any other combo of output streams for
> that matter).


I *want* inter-leaving. I *want* perfect, line-by-line
inter-leaving. Because what I want is detailed logging
just *before* JUnit reports failure. If there is more
than one test in your testsuite you tend to get all the Log4J
messages, and then all the JUnit failure reports, rendering
it difficult (and tiresome, and tedious etc) to make a useful
1:1 mapping between the two.

If I could turn off all buffering it would give me the output
I want, although possibly the performance would suffer.

BugBear

Chris 01-22-2004 09:53 AM

Re: log4j messages out of order w.r.t JUnit under Ant?
 
> I *want* inter-leaving. I *want* perfect, line-by-line
> inter-leaving. Because what I want is detailed logging
> just *before* JUnit reports failure. If there is more
> than one test in your testsuite you tend to get all the Log4J
> messages, and then all the JUnit failure reports, rendering
> it difficult (and tiresome, and tedious etc) to make a useful
> 1:1 mapping between the two.


Then a better solution would be to run only the test(s) that are
failing. There's no point dumping all the log output for tests that
work, or repeatedly running passed tests when you're trying to sort
out the broken ones.

When fixing tests using Junit/ANT I run single test-case classes or
even an individual test method rather than the lot.

The following java.net article outlines how to do this nicely:

http://today.java.net/pub/a/today/20...html?page=last

Hope this helps.

- sarge

bugbear 01-28-2004 11:35 AM

Re: log4j messages out of order w.r.t JUnit under Ant?
 
sarge_chris@hotmail.com (Chris) wrote in message news:<568394b1.0401220153.28faef12@posting.google. com>...
> > I *want* inter-leaving. I *want* perfect, line-by-line
> > inter-leaving. Because what I want is detailed logging
> > just *before* JUnit reports failure. If there is more
> > than one test in your testsuite you tend to get all the Log4J
> > messages, and then all the JUnit failure reports, rendering
> > it difficult (and tiresome, and tedious etc) to make a useful
> > 1:1 mapping between the two.

>
> Then a better solution would be to run only the test(s) that are
> failing. There's no point dumping all the log output for tests that
> work, or repeatedly running passed tests when you're trying to sort
> out the broken ones.
>
> When fixing tests using Junit/ANT I run single test-case classes or
> even an individual test method rather than the lot.
>
> The following java.net article outlines how to do this nicely:
>
> http://today.java.net/pub/a/today/20...html?page=last
>
> Hope this helps.


I think it will.

It addresses my principal problem, and renders
my actual question (about line buffering and stuff)
irrelevant.

I guess this is the very best kind
of topic drift :-)

Bugbear


All times are GMT. The time now is 07:19 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.