log4j messages out of order w.r.t JUnit under Ant?

Discussion in 'Java' started by bugbear, Jan 20, 2004.

  1. bugbear

    bugbear Guest

    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
    bugbear, Jan 20, 2004
    #1
    1. Advertising

  2. bugbear

    Chris Guest

    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
    Chris, Jan 20, 2004
    #2
    1. Advertising

  3. bugbear

    bugbear Guest

    (Chris) wrote in message news:<>...
    > 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
    bugbear, Jan 21, 2004
    #3
  4. bugbear

    Chris Guest

    > 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/2003/09/12/individual-test-cases.html?page=last

    Hope this helps.

    - sarge
    Chris, Jan 22, 2004
    #4
  5. bugbear

    bugbear Guest

    (Chris) wrote in message news:<>...
    > > 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/2003/09/12/individual-test-cases.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
    bugbear, Jan 28, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandra Stehman

    eclipse, junit, log4j, & finding log4j.xml

    Alexandra Stehman, Jan 19, 2004, in forum: Java
    Replies:
    0
    Views:
    5,751
    Alexandra Stehman
    Jan 19, 2004
  2. Paul Carey

    Log4j and JUnit conflict

    Paul Carey, May 21, 2004, in forum: Java
    Replies:
    0
    Views:
    1,189
    Paul Carey
    May 21, 2004
  3. Alex Hunsley
    Replies:
    2
    Views:
    12,910
    =?ISO-8859-15?Q?Fr=E9d=E9ric_G=E9din?=
    May 28, 2004
  4. BlueDolphin

    log4j and console in ANT/JUnit task

    BlueDolphin, Oct 21, 2004, in forum: Java
    Replies:
    6
    Views:
    10,154
    BlueDolphin
    Oct 23, 2004
  5. nospawn
    Replies:
    2
    Views:
    1,137
    Giovanni Azua
    Feb 3, 2006
Loading...

Share This Page