Griffon
  1. Griffon
  2. GRIFFON-444

Implement Grails like Capability to Change Logging Backends

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.4
    • Fix Version/s: 0.9.5-rc1
    • Component/s: cli, rt
    • Labels:
      None
    • Number of attachments :
      0

      Description

      add the capability to exchange the defauly log4j logging implementation with a different framework (e.g. logback). Ideally the mechanism to do so would be identical to Grails as outlined in this article: http://www.lazygun.net/grails-replacing-log4j-with-logback

      See the griffon user mailing list discussion: How does one replace log4j with logback

        Activity

        Hide
        Andres Almiray added a comment -

        Instructions as explained on that blog post do work for Griffon too.

        1. Exclude log4j dependencies from global space, but do not exclude log4j-1.2.16 as it will cause a CNFE at runtime (some classes are required by the logging DSL).

        2. configure Logback in the dependency DSL, like this

        griffon.project.dependency.resolution = {
            inherits("global") {
                excludes 'slf4j-log4j12', 'log4j-over-slf4j'
            }
            log "warn"
            repositories {
                griffonHome()
                mavenCentral()
            }
            dependencies {
                String logbackVersion = '1.0.0'
                build   "ch.qos.logback:logback-core:$logbackVersion",
                        "ch.qos.logback:logback-classic:$logbackVersion"
                runtime "ch.qos.logback:logback-core:$logbackVersion",
                        "ch.qos.logback:logback-classic:$logbackVersion"
            }
        }
        

        3. Create a suitable Logback configuration in griffon-app/conf/resources/logback.xml

        <configuration debug="true" scan="true" scanPeriod="30 seconds">
          <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <layout>
              <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
            </layout>
          </appender>
        
          <logger name="griffon" level="INFO"/>
          <logger name="org.codehaus.griffon" level="DEBUG"/>
        
          <root level="warn">
            <appender-ref ref="STDOUT" />
          </root>
        </configuration>
        

        4. Profit!

        Show
        Andres Almiray added a comment - Instructions as explained on that blog post do work for Griffon too. 1. Exclude log4j dependencies from global space, but do not exclude log4j-1.2.16 as it will cause a CNFE at runtime (some classes are required by the logging DSL). 2. configure Logback in the dependency DSL, like this griffon.project.dependency.resolution = { inherits( "global" ) { excludes 'slf4j-log4j12', 'log4j-over-slf4j' } log "warn" repositories { griffonHome() mavenCentral() } dependencies { String logbackVersion = '1.0.0' build "ch.qos.logback:logback-core:$logbackVersion" , "ch.qos.logback:logback-classic:$logbackVersion" runtime "ch.qos.logback:logback-core:$logbackVersion" , "ch.qos.logback:logback-classic:$logbackVersion" } } 3. Create a suitable Logback configuration in griffon-app/conf/resources/logback.xml <configuration debug= " true " scan= " true " scanPeriod= "30 seconds" > <appender name= "STDOUT" class= "ch.qos.logback.core.ConsoleAppender" > <layout> <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern> </layout> </appender> <logger name= "griffon" level= "INFO" /> <logger name= "org.codehaus.griffon" level= "DEBUG" /> <root level= "warn" > <appender-ref ref= "STDOUT" /> </root> </configuration> 4. Profit!
        Hide
        Andres Almiray added a comment -

        Disabling all Log4j dependencies and enabling a Logback DSL would be different RFEs.

        Show
        Andres Almiray added a comment - Disabling all Log4j dependencies and enabling a Logback DSL would be different RFEs.
        Hide
        Richard Freedman added a comment -

        I found that for Griffon, putting a logback.groovy DSL config file in griffon-app/resources works.
        I haven't tried it for Grails yet, YMMV.

        Show
        Richard Freedman added a comment - I found that for Griffon, putting a logback.groovy DSL config file in griffon-app/resources works. I haven't tried it for Grails yet, YMMV.

          People

          • Assignee:
            Andres Almiray
            Reporter:
            Stephen Nesbitt
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: