首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Groovy配置Log4j

Groovy配置Log4j
EN

Stack Overflow用户
提问于 2020-12-24 20:06:06
回答 1查看 323关注 0票数 0

我有一项任务要处理我们的旧Grails应用程序,它是由我们以前的同事开发的。使用的grails应用程序版本为2.2.5,运行在Java1.7上。当我运行这个应用程序时,我得到以下信息:(关于plugins.log4j.Log4jConfig.methodMissing BeanUtils)

解析运行时依赖项..。org.codehaus.groovy.grails.plugins.log4j.Log4jConfig.methodMissing(Log4jConfig.groovy:103) /apache/commons/BeanUtils/BeanUtils/BeanUtils/BeanUtils/BeanUtils/ Error java.lang.NoClassDefFoundError: org/apache/Method/BeanUtils/BeanUtils/BeanUtils在sun.reflect.NativeMethodAccessorImpl.invoke0(Native方法中的错误)

该应用程序确实运行,但没有日志,因为上述错误信息。因为没有日志,所以跟踪和理解代码是不可能的。谢谢您的帮助。

下面是BuildConfig.groovy中的依赖项和插件

代码语言:javascript
复制
dependencies {
    runtime 'mysql:mysql-connector-java:5.1.22'
    test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
    compile "org.jadira.usertype:usertype.jodatime:1.9"
    runtime 'com.paypal.sdk:rest-api-sdk:0.7.0'
}

plugins {
    runtime ":hibernate:$grailsVersion"
    runtime ":jquery:1.8.3"
    runtime ":resources:1.1.6"
    compile ':runtime-logging:0.4'
    build ":tomcat:$grailsVersion"
    compile ":spring-security-core:1.2.7.3"     
    compile ":spring-security-ui:0.2"
    compile ":famfamfam:1.0.1"
    compile ":jquery-ui:1.8.24"
    compile ":joda-time:1.4"
    compile ":quartz:1.0-RC6"
    compile ":audit-logging:0.5.4"
    compile ":console:1.2"
    compile ":mail:1.0.1"
    compile ":kickstart-with-bootstrap:0.9.6"
    runtime ":database-migration:1.3.6"
    compile ':cache:1.0.1'
    compile ':crypto:2.0'
    compile ":csv:0.3.1"
    test ":code-coverage:1.2.6"
    compile ":gmetrics:0.3.1"
    compile ":codenarc:0.23"
    compile ":export:1.6"
}

和Log4j在Config.groovy中的配置

代码语言:javascript
复制
log4j = {
def gbPattern = pattern(conversionPattern: "%d{dd MMM yyyy HH:mm:ss} [%X{user_rid},%X{user_name},%X{user_action}] [%5p] %-30.30c{2} %m%n")
def infoLog = "${new File('./logs').exists() ? './logs' : '/tmp/'}/info.log"
def debugLog = "${new File('./logs').exists() ? './logs' : '/tmp/'}/debug.log"

appenders {
    console name: 'stdout', layout: gbPattern
    appender new DailyRollingFileAppender(
            name: 'debugLog',
            threshold: org.apache.log4j.Level.DEBUG,
            datePattern: "'.'yyyy-MM-dd",  // See the API for all patterns.
            fileName: debugLog,
            layout: gbPattern
    )
    appender new DailyRollingFileAppender(
            name: 'rollingLog',
            threshold: org.apache.log4j.Level.INFO,
            datePattern: "'.'yyyy-MM-dd",  // See the API for all patterns.
            fileName: infoLog,
            layout: gbPattern
    )
}

root {
    if(Environment.isDevelopmentMode()) {
        info 'stdout', 'rollingLog', 'debugLog'
    } else {
        info 'rollingLog', 'debugLog'

    }

    additivity = false
}
EN

回答 1

Stack Overflow用户

发布于 2020-12-28 07:31:24

尝试在插件中的BuildConfig.groovy中添加下面的依赖项:

代码语言:javascript
复制
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65442822

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档