Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1232

Groovy configuration for maxFileSize is broken in 1.1.8

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.1.8
    • Fix Version/s: 1.1.8
    • Component/s: None
    • Labels:
      None

      Description

      I'm testing on 1.1.8-SNAPSHOT and found that my existing Groovy configuration file is no longer working. An exception is thrown on

      maxFileSize="50MB"
      
      Failed to instantiate [ch.qos.logback.classic.LoggerContext]
      Reported exception:
      org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '50MB' with class 'java.lang.String' to class 'ch.qos.logback.core.util.FileSize'
              at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformatio
      n.java:402)
              at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransforma
      tion.java:316)
              at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:
      229)
              at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2690)
              at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3747)
              at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:196)
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:482)
              at ch.qos.logback.classic.gaffer.PropertyUtil.attach(PropertyUtil.groovy:44)
              at ch.qos.logback.classic.gaffer.PropertyUtil$attach$2.call(Unknown Source)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
              at ch.qos.logback.classic.gaffer.PropertyUtil$attach$2.call(Unknown Source)
              at ch.qos.logback.classic.gaffer.ComponentDelegate.propertyMissing(ComponentDelegate.groovy:92)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
              at groovy.lang.MetaClassImpl.invokeMissingProperty(MetaClassImpl.java:878)
              at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2722)
              at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3747)
              at ch.qos.logback.classic.gaffer.ComponentDelegate.setProperty(ComponentDelegate.groovy)
              at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:192)
              at groovy.lang.Closure.setPropertyTryThese(Closure.java:388)
              at groovy.lang.Closure.setPropertyDelegateFirst(Closure.java:378)
              at groovy.lang.Closure.setProperty(Closure.java:359)
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setGroovyObjectProperty(ScriptBytecodeAdapter.java:530)
              at logback$_run_closure1$_closure8.doCall(logback.groovy:53)
              at logback$_run_closure1$_closure8.doCall(logback.groovy)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
              at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
              at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1017)
              at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
              at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
              at ch.qos.logback.classic.gaffer.ComponentDelegate.methodMissing(ComponentDelegate.groovy:64)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
              at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:934)
              at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1257)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1210)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1017)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:808)
              at ch.qos.logback.classic.gaffer.ComponentDelegate.invokeMethod(ComponentDelegate.groovy)
              at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:428)
              at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:369)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1017)
              at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:169)
              at logback$_run_closure1.doCall(logback.groovy:52)
              at logback$_run_closure1.doCall(logback.groovy)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
              at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
              at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1017)
              at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
              at ch.qos.logback.classic.gaffer.ConfigurationDelegate.appender(ConfigurationDelegate.groovy:211)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
              at org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod.invoke(MixinInstanceMetaMethod.java:53)
              at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMet
      hodSite.java:248)
              at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:177)
              at logback.run(logback.groovy:45)
              at logback$run.call(Unknown Source)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
              at ch.qos.logback.classic.gaffer.GafferConfigurator.run(GafferConfigurator.groovy:60)
              at ch.qos.logback.classic.gaffer.GafferUtil.runGafferConfiguratorOn(GafferUtil.java:43)
              at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:67)
              at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
              at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
              at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
              at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
              at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
              at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
              at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
              at org.apache.log4j.Category.<init>(Category.java:57)
              at org.apache.log4j.Logger.<init>(Logger.java:37)
              at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:43)
              ...
      

      This is likely caused by commit 03e26684d43066d53dbf926e060a73d43bee77fd, where the maxFileSize property seems to be changed from type String to type FileSize.

      It is possible to workaround this issue by changing logback.groovy to:

      import ch.qos.logback.core.util.FileSize;
      
      ...
      
      maxFileSize=FileSize.valueOf("50MB");
      

      When moving back to release 1.1.7 the error is gone.

        Attachments

          Activity

            People

            • Assignee:
              ceki Ceki Gülcü
              Reporter:
              forsel Frans Orsel
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: