I am trying to replace log4j in my Grails app with logback but am always getting a
Embedded error: java.lang.reflect.InvocationTargetException
org.apache.log4j.LogManager
when running run-app or test-app.
I have included the following in BuildConfig.groovy which I thought is enough:
inherits("global") {
excludes "slf4j-log4j12"
}
[...]
dependencies {
build 'ch.qos.logback:logback-core:0.9.29', 'ch.qos.logback:logback-classic:0.9.29'
runtime 'ch.qos.logback:logback-core:0.9.29', 'ch.qos.logback:logback-classic:0.9.29'
}
I cannot find any more references to Log4J and have no idea where this call comes from?!
I am also trying replace Grails slf 1.5.8 by 1.6.2 and get the following in the console despite having excluded slf from all Grails modules:
SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
Thanks in advance for any help
Regards,
Jonas
Logback 0.9.21 and above depends on slf4j-api 1.6 which is what that error is telling you.
Add dependencies for org.slf4j:slf4j-api:1.6
This worked for me in BuildConfig.groovy when using Grails 2.1.0:
inherits("global") {
excludes 'grails-plugin-log4j'
}
[...]
dependencies {
compile 'ch.qos.logback:logback-classic:1.0.6'
runtime 'ch.qos.logback:logback-classic:1.0.6'
}
[...]
this.classLoader.rootLoader.addURL(new File("${basedir}/grails-app/conf/").toURI().toURL())
This last line makes Grails properly read grails-app/conf/logback.groovy if you want to set your configuration there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With