我與Grails的2.1.1發展,現在我想的logback(http://logback.qos.ch)整合爲默認的日誌框架,它應該提供一些更好的日誌記錄功能也可以通過Groovy進行配置。的Grails 2.1.1 - 集成的logback
的logback爲1.0.7(最新的),並只與slf4j 1.6.6
我想升級Grails的dependeny工作。 Grails 2.1.1使用的是slf4j 1.6.2
。如何正確地做到這一點?
我試過如下:在BuildConfig.groovy
我排除grails-plugin-log4j
和slf4j-api
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
excludes "grails-plugin-log4j", "slf4j-api"
}
...
}
,我嘗試在compile
build
和runtime
加載slf4j-api 1.6.6
與其他必要的庫一起
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"
}
...
}
現在,如果我想要從Grails命令行中執行任何操作,可以是grails compile
或grails clean
,它可以是
| 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
我怎樣才能正確地升級底層slf4j-api
:寧認爲,因爲它找不到的LoggerFactory類它不能執行該腳本?
如果我不排除slf4j-api
第一,我與「舊」 1.6.2 API標記爲驅逐衝突調用grails dependency-report
當...
另外,我很想有一個外部Logback的配置文件。我將如何實現它?在Log4j中,我只是在conf/spring/resources.groovy
文件中聲明瞭log4jConfigurer
bean - 如何使用Logback完成該操作?
先後在伐木的Grails 2.1.1的logback任何經驗,可以給我這個問題有什麼建議?
使用logback grails插件怎麼樣? http://grails.org/plugin/logback – tbruyelle
感謝您的建議 - 似乎Burt在10天前上傳了插件...所以,從我的問題日期可以看出,該插件一定是在發展或者在目前沒有想到。 插件本身看起來很有前途!我肯定會檢查出來的!此外,仍然存在IDE日誌對象缺少IDE轉換支持的問題......黑客利用Intellij IDEA插件來完成這個問題,但它似乎不是一個'漂亮'的解決方案...我也爲此提交了一個Bug報告:http://youtrack.jetbrains.com/issue/IDEA-97383 – herom
apache和sl4j的日誌對象有什麼區別?我的意思是它們都暴露標準的日誌方法,如'info()','error()','debug()'。 – tbruyelle