Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed stale reference to log4j-groovy

...

in file %JAVA_HOME%/jre/lib/logging.properties or equivalent

  • make sure your log handler is configured to show level 'FINER' at least,
    e.g.

    Code Block
    
    java.util.logging.ConsoleHandler.level = ALL
    
  • set MetaClass logging to 'FINER' at least,
    e.g.

    Code Block
    
    groovy.lang.MetaClass.level = FINER
    
  • set the appropriate Level for the Classes and optionally method names
    that you want to trace. The name for the appropriate logger starts with
    'methodCalls' and optionally ends with the method name,
    e.g.

    Code Block
    
    # trace all method calls
    methodCalls.level = FINER
    
    # trace method calls to the 'String' class
    methodCalls.java.lang.String.level = FINER
    
    # trace method calls to Object.println()
    methodCalls.java.lang.Object.println.level = FINER
    

Example:
with tracing enabled for all method calls a Groovy command line
script appears as follows (German locale)

Code Block

$ groovy -e "println 'hi'"
13.09.2005 14:33:05 script_from_command_line run()
FEINER: called from MetaClass.invokeMethod
13.09.2005 14:33:05 script_from_command_line println('hi')
FEINER: called from MetaClass.invokeMethod
hi

LOG4J-GROOVY

There is one problem with loggers and groovy: Script name and line number is wrong. Groovy is using some bytecode magic which is confusing loggers. It is big problem for debugging, also message filtering by classes does not work.

There is simple patch for LOG4J which solve it. With it, LOG4J correctly shows file names and line numbers when invoked from Groovy. For more details check http://www.kotek.net/projects/log4j-groovy