3

Sorry, this is probably a very simple question.

I am using gradle for my development environment. It works quite well!

I have written a simple unit test that uses HtmlUnit and my own package.

For my own package, I use java.util.Logger.

HtmlUnit seems to use commons logging.

I would like to see console output of my logging messages from java.util.Logger

However, it seems that even messages at the info level are not displayed in my Unit Test Results GUI (System.err link), although the HtmlUnit messages are all displayed.

Please let me know if you have suggestions.

Thank you! Misha

1
  • One more hint: it seems that if I use a Logger within the actual test class, everything works well. However, my logger is inside the class being tested, and that output does not seem to get processed properly. Commented Jun 7, 2010 at 18:40

2 Answers 2

2

Ok. I figured it out. It was quite odd.

Namely, if I initialize the logger outside of any methods:

class foo {
   def log=Logger.getLogger(this.class.name)
}

log output is not seen when I write a test.

However, if I initialize the logger inside the constructor

class foo {
   def log
   foo() {
      log=Logger.getLogger(this.class.name)
   }
}

Then it works fine. Odd...

Thank you! Misha

Sign up to request clarification or add additional context in comments.

Comments

0

Bridging logging systems from library's that use their own is complicated. Why not use slf4j's bridging JAR's? They will redirect old calls to commons logging to it's own logging system which YOU design against.

Take a look at http://www.slf4j.org/legacy.html

1 Comment

Thank you. I'm still a bit confused though. Which logging output can I use that will get displayed in the Unit Test Results? I mean for my own programs. Thank you Misha

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.