Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4609

Using log variable created with @Log or @Log4j causes compiler error if used in static method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8-beta-3
    • 1.8-rc-1, 1.9-beta-1
    • None
    • None

    Description

      If I have a class with it and use the 'log' variable in a static method I get a compilation error.

      Log4jTest.groovy:
      import groovy.util.logging.Log4j

      @Log4j
      class TestLog4j {

      public static void main(String[] args)

      { log.info "Hello World" }

      }

      Error Message:
      Apparent variable 'log' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
      You attempted to reference a variable in the binding or an instance variable from a static context.
      You misspelled a classname or statically imported field. Please check the spelling.
      You attempted to use a method 'log' but left out brackets in a place not allowed by the grammar.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            krush Kurt Rush
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: