Results 1 to 6 of 6

Thread: log4j on GroovyTestCase extraneous poo

Hybrid View

  1. #1

    Default log4j on GroovyTestCase extraneous poo

    Whenever I run a GroovyTestCase in Springsource Toolsuite, and log at INFO, I get the following in every log invocation:

    Code:
    Apr 26, 2011 4:58:36 PM sun.reflect.GeneratedMethodAccessor3 invoke
    INFO: foo
    Apr 26, 2011 4:58:36 PM sun.reflect.GeneratedMethodAccessor3 invoke
    INFO: bar
    Does anyone know how to turn this off?

    Brian

  2. #2
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Which version of Grails? I guess this may be a Groovy thing, in which case I'm not sure what you can do other than to disable those particular log messages.

  3. #3

    Default Grails version

    I'm using version 1.3.7. I've seen this since 1.3.4 with groovy.util.GroovyLog.

    Brian

  4. #4
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    I've got to say, I'm a bit confused because the GroovyTestCase logging is based on java.util.logging, so changing the Grails project's logging level to 'info' shouldn't make any difference (since that affects log4j). Unless you are using java.util.logging in your project?

  5. #5

    Default My imports

    Here are my imports:

    Code:
    import static org.junit.Assert.*
    import groovy.sql.Sql
    import groovy.util.GroovyTestCase
    import groovy.util.GroovyLog.*
    import org.junit.Test
    
    @Test
    void testStuff() {
        log.info 'Starting test'
    }
    which results in:

    Code:
    May 4, 2011 12:41:50 PM sun.reflect.NativeMethodAccessorImpl invoke0
    INFO: Starting test
    Brian

  6. #6
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Ah, I understand now (I think). The 'log' property in GroovyTestCase is an instance of java.util.logging.Logger, which is not controlled by the Grails logging system. I did look into this, but I've forgotten how to configure java.util.logging.*. I would try a web search.

    As for GroovyLog, I'm not sure what that's used for. It's been deprecated for a while I think. With Grails 1.4 you will be able to add an @Log annotation and hook into the Grails logging environment. We will also encourage people to stop using GroovyTestCase, because there will be better alternatives.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •