在Grails中构建WAR时移除Log4j jar
下面是我在Config.groovy中的log4j代码片段在Grails中构建WAR时移除Log4j jar,grails,tomcat7,grails-plugin,Grails,Tomcat7,Grails Plugin,下面是我在Config.groovy中的log4j代码片段 log4j = { appenders { console name: 'stdout', layout: pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{2} - %m\n') rollingFile name:'file', file:'/home/user/logs/app.log', maxFileSize:
log4j = {
appenders {
console name: 'stdout', layout: pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{2} - %m\n')
rollingFile name:'file', file:'/home/user/logs/app.log', maxFileSize:'5MB', maxBackupIndex:2
}
root {
info "stdout"
}
info file: "grails.app"
}
grails.servlet.version = "2.5"
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
grails.project.dependency.resolution = {
inherits("global") {
excludes 'serializer'
}
log "warn"
checksums true
repositories {
inherits true
grailsPlugins()
grailsHome()
grailsCentral()
}
dependencies {
runtime 'mysql:mysql-connector-java:5.1.20'
compile "commons-httpclient:commons-httpclient:3.1"
compile "it.svario.xpathapi:xpathapi-jaxp:0.3"
build 'org.apache.httpcomponents:httpcore:4.3'
build 'org.apache.httpcomponents:httpclient:4.3.1'
build 'org.apache.commons:commons-lang3:3.1'
runtime 'org.apache.httpcomponents:httpcore:4.3'
runtime 'org.apache.httpcomponents:httpclient:4.3.1'
runtime 'org.apache.commons:commons-lang3:3.1'
}
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.2"
runtime ":resources:1.1.6"
compile ":rest:0.8"
build ":tomcat:$grailsVersion"
compile ':cache:1.0.0'
compile ":spring-events:1.2"
}
}
grails.plugin.location.'module' = "../module"
这是我的BuildConfig.groovy
log4j = {
appenders {
console name: 'stdout', layout: pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{2} - %m\n')
rollingFile name:'file', file:'/home/user/logs/app.log', maxFileSize:'5MB', maxBackupIndex:2
}
root {
info "stdout"
}
info file: "grails.app"
}
grails.servlet.version = "2.5"
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
grails.project.dependency.resolution = {
inherits("global") {
excludes 'serializer'
}
log "warn"
checksums true
repositories {
inherits true
grailsPlugins()
grailsHome()
grailsCentral()
}
dependencies {
runtime 'mysql:mysql-connector-java:5.1.20'
compile "commons-httpclient:commons-httpclient:3.1"
compile "it.svario.xpathapi:xpathapi-jaxp:0.3"
build 'org.apache.httpcomponents:httpcore:4.3'
build 'org.apache.httpcomponents:httpclient:4.3.1'
build 'org.apache.commons:commons-lang3:3.1'
runtime 'org.apache.httpcomponents:httpcore:4.3'
runtime 'org.apache.httpcomponents:httpclient:4.3.1'
runtime 'org.apache.commons:commons-lang3:3.1'
}
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.2"
runtime ":resources:1.1.6"
compile ":rest:0.8"
build ":tomcat:$grailsVersion"
compile ':cache:1.0.0'
compile ":spring-events:1.2"
}
}
grails.plugin.location.'module' = "../module"
使用的grails版本是2.2.4。当grails运行app时,它工作正常。构建war时,war中不包含log4j库
如果手动添加库,则会抑制异常。但是,日志不会写入app.log
有人能提供解决方案吗
更新:此应用程序中使用了Quartz 1.0-RC9插件。这是否有可能与log4j冲突?运行
grails依赖关系报告
,查看quartz是否存在问题。我觉得你说得对。@dmahapatro:谢谢。试过以上命令。依赖项报告中未报告任何错误。可以在IDE的类路径中看到log4j库。只有当构建到战争中(从IDE或命令提示符)时,它才会在战争中丢失。