On 29/10/2010, at 3:00 PM, Gianni wrote:

> On 29/ott/2010, at 02.00, Adam Murdoch wrote:
>> On 28/10/2010, at 8:14 PM, Gianni wrote:
>> 
>>> Any ideas how I can view the slf4j log messages output from classes run as 
>>> part of my testng test suite?
>> 
>> You can't at the moment. The idea is that you're supposed to use a TestNG 
>> reporter: http://testng.org/javadocs/org/testng/Reporter.html. Which is 
>> probably not a great idea.
>> 
>> We plan to add some way to see the test logging output on the console. 
>> There's a JIRA issue, if you want to vote for it: 
>> http://jira.codehaus.org/browse/GRADLE-1009
>> 
>> There are some workaround possible. Which slf4j binding are you using in 
>> your tests?
> 
> Thanks for the clarification.
> I'm using logback.


Here's a chunk of code to configure logback:

        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        OutputStreamAppender<ILoggingEvent> appender = new 
OutputStreamAppender<ILoggingEvent>();
        appender.setContext(lc);
        FileOutputStream outputStream = new 
FileOutputStream(FileDescriptor.out);
        PatternLayout layout = new PatternLayout();
        layout.setPattern("[%level] [%c] %m%n%ex");
        layout.setContext(lc);
        layout.start();
        appender.setLayout(layout);
        appender.setOutputStream(outputStream);
        Logger root = lc.getLogger("ROOT");
        root.addAppender(appender);
        root.setLevel(Level.ALL);
        appender.start();

This needs to get executed by the tests. You could pop this in a @BeforeTest 
method somewhere, and it will get run before any of the test methods get run.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to