Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.3.5
-
Component/s: Documentation
-
Labels:None
Description
Much of the confusion over logging during the test phase seems to be related to the 'log' property.
Throughout Grails, log4j is used as the logging framework and automagically exposed as the 'log' property. However, when writing a test case, the 'log' property (inherited from groovy.util.GroovyTestCase) is a java.util.logging.Logger. The documentation should make a note of this 'gotcha'.
MyController.groovy
class MyController {
def index = {
log.debug('This is a debug message in the controller') //log4j
}
}
MyControllerTests.groovy
class MyControllerTests extends ControllerUnitTestCase { void testIndex() { def model = controller.index() log.finer('This is a debug-ish message in the unit test code') //java.util.logging } }
I have to admit, I didn't know about that log property.