Viewing Log4J output in Ipr runner

Hello JBers,

How do I get TeamCity to display Log4J log messages in build results? I
have a very simple test that logs an error message and then fails, but I
can't get the error message to display apart from writing it explicitly
to System.out or System.err. I have tried:
1) A simple log4j.properties file which sets up a ConsoleAppender on the
ROOT
2) Hard-coding a ConsoleAppender in the setup of my test
Neither seems to work. Is TeamCity magic interfering, or am I just
being dense? Have you got any hints for me? (I'm using TC 3.0.1.)

R

PS Here are is my log4j.properties
log4j.rootLogger=INFO, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c
%x - %m%n

and here is my stupid test with log message
package com.blahblah.tests;

import junit.framework.TestCase;
import org.apache.log4j.Logger;

/**

  • @author Last modification : $Date: 2006-10-26 15:03:25 +0200 (Thu,

26 Oct 2006) $

  • @author by $Author: rgibson $ S.D.G.

*/
public class TestTest extends TestCase
{
private static final Logger logger = Logger.getLogger (TestTest.class);

public void testAThing ()
{
logger.error ("Oops, an error");
throw new AssertionError ("Oops");
}
}

2 comments

Hello Robert,

Given that you use log4j 1.2.13+, you should add the 'Follow' option to ConsoleAppender.

See issue http://www.jetbrains.net/jira/browse/TW-3022 for details.

Hope this helps,
KIR

0

OK, I was using 1.2.9. Upgrading to 1.2.15 and setting follow=true on
my Console appender fixes my problem.
Thanks,
Robert

0

Please sign in to leave a comment.