|
I am not seeing any logging from my classes show up in the STS while running my unit tests. These are Spock tests.
I understand that prior to Grails 2, mockLogging() was used to change the log statements to println statements, but that the TestMixin should do that in Grails 2.
Am I missing something? In my Spock test, I'm using @TestFor(MyClass), but I don't see any logging from MyClass when run in STS. Can someone point me in the right direction?
thanks! |
|
Actually, when I up the log levels to error or warn, I *do* see those in the console.
I really need to see trace levels. Can anyone point me to the magic where this is being done, so I can lower the level?
thanks.
On Fri, Jun 1, 2012 at 1:16 PM, David Hay <[hidden email]> wrote: I am not seeing any logging from my classes show up in the STS while running my unit tests. These are Spock tests. |
|
I'd really like to figure this out. Can anyone shed light on the subject?
thanks!
On Fri, Jun 1, 2012 at 2:21 PM, David Hay <[hidden email]> wrote: Actually, when I up the log levels to error or warn, I *do* see those in the console. |
|
Administrator
|
Silly question maybe, but have you tried upping the level to trace? ;-)
Cheers On Thu, Jun 7, 2012 at 9:27 PM, David Hay <[hidden email]> wrote: > I'd really like to figure this out. Can anyone shed light on the subject? > > thanks! > > > On Fri, Jun 1, 2012 at 2:21 PM, David Hay <[hidden email]> wrote: >> >> Actually, when I up the log levels to error or warn, I *do* see those in >> the console. >> >> I really need to see trace levels. Can anyone point me to the magic where >> this is being done, so I can lower the level? >> >> thanks. >> >> >> On Fri, Jun 1, 2012 at 1:16 PM, David Hay <[hidden email]> wrote: >>> >>> I am not seeing any logging from my classes show up in the STS while >>> running my unit tests. These are Spock tests. >>> >>> I understand that prior to Grails 2, mockLogging() was used to change the >>> log statements to println statements, but that the TestMixin should do that >>> in Grails 2. >>> >>> Am I missing something? In my Spock test, I'm using @TestFor(MyClass), >>> but I don't see any logging from MyClass when run in STS. >>> >>> Can someone point me in the right direction? >>> >>> thanks! >>> >>> >> > -- Graeme Rocher Grails Project Lead SpringSource - A Division of VMware http://www.springsource.com --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Hi Graeme,
Yep, I did that :) It appears that when running in STS that does not change anything.
Here's what it looks like: 1) if nothing is added, @TestFor provides logging for the object at WARN level
2) if the STATIC method mockLogging(object, true) is added, logging is provided at the DEBUG level. 3) there is no way to set the level to TRACE Unfortunate, as this is what we use.
It appears that in the mockLogging() method in grails.test.MockUtils, the log level switch statement does nothing for TRACE. Can anyone explain how the TestFor provides logging, and how I would change it to provide TRACE level logging?
thanks! On Thu, Jun 7, 2012 at 3:37 PM, Graeme Rocher <[hidden email]> wrote: Silly question maybe, but have you tried upping the level to trace? ;-) |
|
Administrator
|
The TestFor annotation does nothing in terms of logging, as far as i'm
aware. It may be that log4j needs initializing for tests run in STS Cheers On Thu, Jun 7, 2012 at 10:02 PM, David Hay <[hidden email]> wrote: > Hi Graeme, > > Yep, I did that :) It appears that when running in STS that does not change > anything. > > Here's what it looks like: > > 1) if nothing is added, @TestFor provides logging for the object at WARN > level > 2) if the STATIC method mockLogging(object, true) is added, logging is > provided at the DEBUG level. > 3) there is no way to set the level to TRACE > > Unfortunate, as this is what we use. > > It appears that in the mockLogging() method in grails.test.MockUtils, the > log level switch statement does nothing for TRACE. > > Can anyone explain how the TestFor provides logging, and how I would change > it to provide TRACE level logging? > > thanks! > > > On Thu, Jun 7, 2012 at 3:37 PM, Graeme Rocher <[hidden email]> wrote: >> >> Silly question maybe, but have you tried upping the level to trace? ;-) >> >> Cheers >> >> On Thu, Jun 7, 2012 at 9:27 PM, David Hay <[hidden email]> wrote: >> > I'd really like to figure this out. Can anyone shed light on the >> > subject? >> > >> > thanks! >> > >> > >> > On Fri, Jun 1, 2012 at 2:21 PM, David Hay <[hidden email]> wrote: >> >> >> >> Actually, when I up the log levels to error or warn, I *do* see those >> >> in >> >> the console. >> >> >> >> I really need to see trace levels. Can anyone point me to the magic >> >> where >> >> this is being done, so I can lower the level? >> >> >> >> thanks. >> >> >> >> >> >> On Fri, Jun 1, 2012 at 1:16 PM, David Hay <[hidden email]> wrote: >> >>> >> >>> I am not seeing any logging from my classes show up in the STS while >> >>> running my unit tests. These are Spock tests. >> >>> >> >>> I understand that prior to Grails 2, mockLogging() was used to change >> >>> the >> >>> log statements to println statements, but that the TestMixin should do >> >>> that >> >>> in Grails 2. >> >>> >> >>> Am I missing something? In my Spock test, I'm using >> >>> @TestFor(MyClass), >> >>> but I don't see any logging from MyClass when run in STS. >> >>> >> >>> Can someone point me in the right direction? >> >>> >> >>> thanks! >> >>> >> >>> >> >> >> > >> >> >> >> -- >> Graeme Rocher >> Grails Project Lead >> SpringSource - A Division of VMware >> http://www.springsource.com >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > -- Graeme Rocher Grails Project Lead SpringSource - A Division of VMware http://www.springsource.com --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
I'm running into a similar type of problem and would like a little
clarification on how logging is done when using TestFor. I know TestFor does nothing with logging (I've searched through the code myself to try and find how this was done). The only thing I can figure that it is done as part of the registering the artifact as a spring bean and retrieving it from the application context. To be clear, I'm asking when the log property is actually added or injected into artifacts created using the TestFor transformation during grails unit testing (ie not through STS). This might give David a hint on where to look to lower the logging threshold. Thanks! -Brian -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Graeme Rocher Sent: Thursday, June 07, 2012 3:24 PM To: [hidden email] Subject: Re: [grails-user] Re: console Logging in Grails 2.0.3 unit tests? The TestFor annotation does nothing in terms of logging, as far as i'm aware. It may be that log4j needs initializing for tests run in STS Cheers On Thu, Jun 7, 2012 at 10:02 PM, David Hay <[hidden email]> wrote: > Hi Graeme, > > Yep, I did that :) It appears that when running in STS that does not > change anything. > > Here's what it looks like: > > 1) if nothing is added, @TestFor provides logging for the object at > WARN level > 2) if the STATIC method mockLogging(object, true) is added, logging is > provided at the DEBUG level. > 3) there is no way to set the level to TRACE > > Unfortunate, as this is what we use. > > It appears that in the mockLogging() method in grails.test.MockUtils, > the log level switch statement does nothing for TRACE. > > Can anyone explain how the TestFor provides logging, and how I would > change it to provide TRACE level logging? > > thanks! > > > On Thu, Jun 7, 2012 at 3:37 PM, Graeme Rocher <[hidden email]> >> >> Silly question maybe, but have you tried upping the level to trace? >> ;-) >> >> Cheers >> >> On Thu, Jun 7, 2012 at 9:27 PM, David Hay <[hidden email]> wrote: >> > I'd really like to figure this out. Can anyone shed light on the >> > subject? >> > >> > thanks! >> > >> > >> > On Fri, Jun 1, 2012 at 2:21 PM, David Hay <[hidden email]> >> >> >> >> Actually, when I up the log levels to error or warn, I *do* see >> >> those in the console. >> >> >> >> I really need to see trace levels. Can anyone point me to the >> >> magic where this is being done, so I can lower the level? >> >> >> >> thanks. >> >> >> >> >> >> On Fri, Jun 1, 2012 at 1:16 PM, David Hay <[hidden email]> >> >>> >> >>> I am not seeing any logging from my classes show up in the STS >> >>> while running my unit tests. These are Spock tests. >> >>> >> >>> I understand that prior to Grails 2, mockLogging() was used to >> >>> change the log statements to println statements, but that the >> >>> TestMixin should do that in Grails 2. >> >>> >> >>> Am I missing something? In my Spock test, I'm using >> >>> @TestFor(MyClass), but I don't see any logging from MyClass when >> >>> run in STS. >> >>> >> >>> Can someone point me in the right direction? >> >>> >> >>> thanks! >> >>> >> >>> >> >> >> > >> >> >> >> -- >> Graeme Rocher >> Grails Project Lead >> SpringSource - A Division of VMware >> http://www.springsource.com >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > -- Graeme Rocher Grails Project Lead SpringSource - A Division of VMware http://www.springsource.com --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In the TestForTransformation, the testFor method calls LoggingTransformer.addLogField(classNode, classNode.getName()); This static method is as follows: public static void addLogField(ClassNode classNode, String logName) {
FieldNode logVariable = new FieldNode(LOG_PROPERTY, Modifier.STATIC | Modifier.PRIVATE, new ClassNode(Log.class),
classNode, new MethodCallExpression(new ClassExpression(new ClassNode(LogFactory.class)), "getLog", new ArgumentListExpression(new ConstantExpression(logName))));
classNode.addField(logVariable); } However, I can't figure out how I would set the Log level for for this... cheers,
David On Thu, Jun 7, 2012 at 5:32 PM, Brian Saville <[hidden email]> wrote: I'm running into a similar type of problem and would like a little |
|
Administrator
|
It may be that we need to add logic to TestFor to initialize log4j
from your Config.groovy, which is not currently being done. Feel free to raise a JIRA, and if you do so please attach an example that reproduces the problem Cheers On Fri, Jun 8, 2012 at 1:39 AM, David Hay <[hidden email]> wrote: > In the TestForTransformation, the testFor method calls > LoggingTransformer.addLogField(classNode, classNode.getName()); > > This static method is as follows: > > public static void addLogField(ClassNode classNode, String logName) { > FieldNode logVariable = new FieldNode(LOG_PROPERTY, > Modifier.STATIC | > Modifier.PRIVATE, > new ClassNode(Log.class), > classNode, > new MethodCallExpression(new > ClassExpression(new ClassNode(LogFactory.class)), "getLog", new > ArgumentListExpression(new ConstantExpression(logName)))); > > classNode.addField(logVariable); > } > > However, I can't figure out how I would set the Log level for for this... > > cheers, > > David > > > > > On Thu, Jun 7, 2012 at 5:32 PM, Brian Saville > <[hidden email]> wrote: >> >> I'm running into a similar type of problem and would like a little >> clarification on how logging is done when using TestFor. I know TestFor >> does nothing with logging (I've searched through the code myself to try >> and find how this was done). The only thing I can figure that it is done >> as part of the registering the artifact as a spring bean and retrieving it >> from the application context. >> >> To be clear, I'm asking when the log property is actually added or >> injected into artifacts created using the TestFor transformation during >> grails unit testing (ie not through STS). This might give David a hint on >> where to look to lower the logging threshold. >> >> Thanks! >> -Brian >> >> -----Original Message----- >> From: [hidden email] [mailto:[hidden email]] On Behalf >> Of Graeme Rocher >> Sent: Thursday, June 07, 2012 3:24 PM >> To: [hidden email] >> Subject: Re: [grails-user] Re: console Logging in Grails 2.0.3 unit tests? >> >> The TestFor annotation does nothing in terms of logging, as far as i'm >> aware. It may be that log4j needs initializing for tests run in STS >> >> Cheers >> >> On Thu, Jun 7, 2012 at 10:02 PM, David Hay <[hidden email]> wrote: >> > Hi Graeme, >> > >> > Yep, I did that :) It appears that when running in STS that does not >> > change anything. >> > >> > Here's what it looks like: >> > >> > 1) if nothing is added, @TestFor provides logging for the object at >> > WARN level >> > 2) if the STATIC method mockLogging(object, true) is added, logging is >> > provided at the DEBUG level. >> > 3) there is no way to set the level to TRACE >> > >> > Unfortunate, as this is what we use. >> > >> > It appears that in the mockLogging() method in grails.test.MockUtils, >> > the log level switch statement does nothing for TRACE. >> > >> > Can anyone explain how the TestFor provides logging, and how I would >> > change it to provide TRACE level logging? >> > >> > thanks! >> > >> > >> > On Thu, Jun 7, 2012 at 3:37 PM, Graeme Rocher <[hidden email]> >> wrote: >> >> >> >> Silly question maybe, but have you tried upping the level to trace? >> >> ;-) >> >> >> >> Cheers >> >> >> >> On Thu, Jun 7, 2012 at 9:27 PM, David Hay <[hidden email]> wrote: >> >> > I'd really like to figure this out. Can anyone shed light on the >> >> > subject? >> >> > >> >> > thanks! >> >> > >> >> > >> >> > On Fri, Jun 1, 2012 at 2:21 PM, David Hay <[hidden email]> >> wrote: >> >> >> >> >> >> Actually, when I up the log levels to error or warn, I *do* see >> >> >> those in the console. >> >> >> >> >> >> I really need to see trace levels. Can anyone point me to the >> >> >> magic where this is being done, so I can lower the level? >> >> >> >> >> >> thanks. >> >> >> >> >> >> >> >> >> On Fri, Jun 1, 2012 at 1:16 PM, David Hay <[hidden email]> >> wrote: >> >> >>> >> >> >>> I am not seeing any logging from my classes show up in the STS >> >> >>> while running my unit tests. These are Spock tests. >> >> >>> >> >> >>> I understand that prior to Grails 2, mockLogging() was used to >> >> >>> change the log statements to println statements, but that the >> >> >>> TestMixin should do that in Grails 2. >> >> >>> >> >> >>> Am I missing something? In my Spock test, I'm using >> >> >>> @TestFor(MyClass), but I don't see any logging from MyClass when >> >> >>> run in STS. >> >> >>> >> >> >>> Can someone point me in the right direction? >> >> >>> >> >> >>> thanks! >> >> >>> >> >> >>> >> >> >> >> >> > >> >> >> >> >> >> >> >> -- >> >> Graeme Rocher >> >> Grails Project Lead >> >> SpringSource - A Division of VMware >> >> http://www.springsource.com >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe from this list, please visit: >> >> >> >> http://xircles.codehaus.org/manage_email >> >> >> >> >> > >> >> >> >> -- >> Graeme Rocher >> Grails Project Lead >> SpringSource - A Division of VMware >> http://www.springsource.com >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > -- Graeme Rocher Grails Project Lead SpringSource - A Division of VMware http://www.springsource.com --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
