Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:01:34+00:00 2026-06-15T11:01:34+00:00

I’m developing with Grails 2.1.1 and now I want to integrate Logback (http://logback.qos.ch) as

  • 0

I’m developing with Grails 2.1.1 and now I want to integrate Logback (http://logback.qos.ch) as the default logging framework as it should provide some better logging features and could be also configured via Groovy.

As Logback 1.0.7 (latest) does only work with slf4j 1.6.6 I want to upgrade the Grails dependeny. Grails 2.1.1 is using slf4j 1.6.2. How to do this properly?

I tried the following: in BuildConfig.groovy I exclude grails-plugin-log4j and slf4j-api

grails.project.dependency.resolution = {
  // inherit Grails' default dependencies
  inherits("global") {
      excludes "grails-plugin-log4j", "slf4j-api"
  }
  ...
}

and I try to load slf4j-api 1.6.6 in compile build and runtime along with the other necessary libraries

grails.project.dependency.resolution = {
  ...
  dependencies {
    // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

    compile "org.slf4j:slf4j-api:1.6.6"

    build   "org.slf4j:slf4j-api:1.6.6",
            "ch.qos.logback:logback-core:1.0.7",
            "ch.qos.logback:logback-classic:1.0.7"

    runtime "org.slf4j:slf4j-api:1.6.6",
            "org.slf4j:log4j-over-slf4j:1.6.6", // logback dependency for classic module, as seen on http://logback.qos.ch/dependencies.html
            "ch.qos.logback:logback-core:1.0.7",
            "ch.qos.logback:logback-classic:1.0.7"
}
  ...
}

now, if I want to do anything from the Grails commandline, either grails compile or grails clean, it’s complaining that it couldn’t execute the script because it couldn’t find the LoggerFactory class:

| Loading Grails 2.1.1
| Configuring classpath
| Error Error executing script Compile: org/slf4j/LoggerFactory (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.<clinit>(PathMatchingResourcePatternResolver.java:169)
| Error Error executing script Compile: org/slf4j/LoggerFactory

How can I upgrade the underlying slf4j-api properly?

If I don’t exclude the slf4j-api first, I get a conflict with the “old” 1.6.2 api marked as evicted when calling grails dependency-report…

Also, I’d love to have an external config file for Logback. How would I implement it? With Log4j I just declared a log4jConfigurer bean within the conf/spring/resources.groovy file – how would it be done with Logback?

Has anybody experience in logging Grails 2.1.1 with Logback and could give me any advice for this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:01:36+00:00Added an answer on June 15, 2026 at 11:01 am

    As I think that this question would be also a matter of fact for other developers willing to implement the Logback Logging Framework with Grails, I’ll share my progress on the topic within this answer – trying not to overload the initial question with progress information.

    1. I still had no luck in updating slf4j within Grails, so I stuck
      with the solution to simply overload the slf4j-api dependency.
      Grails would show no error on grails dependency-report, just an
      “eviction notice” on the older slf4j dependency (1.6.2). This seems
      to work but I’ll keep on searching for a better solution on this
      topic.

    2. I’m now able to load an external config file for Logback through
      a ServletContextListener and a ConfigLoader class
      implemented in grails-app/src/java, with the
      ServletContextListener registered within the web.xml file. (to
      get the web.xml simply execute grails install-templates on the
      commandline. You’ll find it under
      grails-app/src/templates/war/web.xml) Be sure to make it the first
      <listener/> entry within your web.xml so that Logback gets
      configured and loaded as soon as possible.

      I found this solution along with the full code sample over at
      https://bowerstudios.com/node/896 which was the best and shortest
      example I found on this topic which seems to work!

      This solution just loaded the external configuration file and used
      it within the ConfigLoader class but didn’t set it for the whole
      Grails application. So I googled around a bit more and I found a
      solution from Logback, available at GitHub (https://github.com/qos-ch/logback-extensions) and integrating with the
      Spring Framework, so I took these classes from this page and
      the LogbackConfigurer class from here and tweaked them to fit
      my needs.

      Now everything works like a charm and I’am able to create an external configuration file and – what I like best – it’s hooking in
      with the log object which is injected to e.g. Controller classes
      by default.

    Hope this is also a help for other developers too 😉

    If you’ve got a better or more “groovy” solution for this, pleas let me know!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.