Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails ClassNotFoundException:org.apache.log4j.Logger_Grails_Logging_Log4j_Logback - Fatal编程技术网

Grails ClassNotFoundException:org.apache.log4j.Logger

Grails ClassNotFoundException:org.apache.log4j.Logger,grails,logging,log4j,logback,Grails,Logging,Log4j,Logback,我正试图让我的Grails应用程序使用。根据文档说明,以下是我迄今为止所做的工作: BuildConfig =========== grails.project.dependency.resolution = { inherits("global") { excludes 'grails-plugin-log4j', 'log4j', 'h2' } log "error" checksums true legacyResolve fals

我正试图让我的Grails应用程序使用。根据文档说明,以下是我迄今为止所做的工作:

BuildConfig
===========
grails.project.dependency.resolution = {
    inherits("global") {
        excludes 'grails-plugin-log4j', 'log4j', 'h2'
    }

    log "error"
    checksums true
    legacyResolve false

    repositories {
        inherits true

        grailsPlugins()
        grailsHome()
        mavenLocal()
        grailsCentral()
        mavenCentral()

        // For logback plugin.
        mavenRepo "http://repo.grails.org/grails/libs-releases/"
    }

    dependencies {
        // This plugin is a binary plugin, so it belongs here instead of under 'plugins'.
        compile 'org.grails.plugins:logback:0.3.1'

        test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
    }
}

Config
======
import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy
import ch.qos.logback.core.rolling.FixedWindowRollingPolicy

<lots of more configs here>

logback = {
    appenders {
    rollingFile name:
        'rollingAppender',
        file: '/tmp/rolling.log',
        encoder: pattern(pattern: '%-4relative [%thread] %-5level %logger{35} - %msg%n'),
        triggeringPolicy: new SizeBasedTriggeringPolicy(maxFileSize: 10*1024*1024),
        rollingPolicy: new FixedWindowRollingPolicy(fileNamePattern: '/tmp/rolling.%i.log.gz')
    }

    root {
        info rollingAppender
    }

    error rollingAppender: 'org.codehaus.groovy.grails.web.servlet',
        'org.codehaus.groovy.grails.web.pages'
}
此外,在我的示例中,我在添加到Config.groovy的两个import语句中遇到了编译器错误。听起来我的Grails应用程序中仍然有Log4j引用,运行Grails clean从我的类路径中删除了Log4j JAR。这也许可以解释stacktrace。但这并不能解释为什么Grails或者至少我的GGTS IDE找不到我导入的logback类

我看到我的配置中仍然有这个:

所以我问:如何修复堆栈跟踪和IDE错误

使现代化 做一个grails依赖关系报告会生成一个巨大的图表,它确实显示了我在log4j上还有两个依赖关系:

+--- org.grails.plugins:tomcat:7.0.54
|    \--- org.apache.tomcat:tomcat-catalina-ant:7.0.53
|    \--- org.apache.tomcat.embed:tomcat-embed-jasper:7.0.53
|         \--- org.apache.tomcat.embed:tomcat-embed-el:7.0.53

<HERE>
|    \--- org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.53

+--- org.grails:grails-plugin-rest:2.4.2
|    \--- org.slf4j:jcl-over-slf4j:1.7.5
|    \--- org.slf4j:slf4j-api:1.7.5
|    \--- com.google.code.gson:gson:2.2.4
|    \--- org.grails:grails-web:2.4.2
|         \--- org.grails:grails-web-common:2.4.2
|              \--- org.springframework:spring-webmvc:4.0.5.RELEASE
|              \--- org.springframework:spring-context-support:4.0.5.RELEASE
|              \--- org.grails:grails-databinding:2.4.2
|         \--- org.grails:grails-web-url-mappings:2.4.2
|         \--- org.grails:grails-web-fileupload:2.4.2
|              \--- commons-fileupload:commons-fileupload:1.3.1
|                   \--- commons-io:commons-io:2.2
|         \--- org.grails:grails-web-gsp:2.4.2
|         \--- org.springframework:spring-aspects:4.0.5.RELEASE
|         \--- org.grails:grails-web-mvc:2.4.2
|         \--- org.grails:grails-web-sitemesh:2.4.2
|              \--- opensymphony:sitemesh:2.4
|         \--- org.grails:grails-web-databinding:2.4.2
|         \--- org.grails:grails-web-jsp:2.4.2
|         \--- org.aspectj:aspectjweaver:1.8.0
|         \--- org.aspectj:aspectjrt:1.8.0
|    \--- org.grails:grails-plugin-controllers:2.4.2
|         \--- org.grails:grails-plugin-validation:2.4.2
|    \--- org.grails:grails-plugin-datasource:2.4.2
|         \--- org.springframework:spring-jdbc:4.0.5.RELEASE

<HERE>
|         \--- org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.50
因此:

org.grails.plugins:tomcat:7.0.54取决于: org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.53;和 org.grails:grails插件rest:2.4.2取决于: org.grails:grails插件数据源:2.4.2,这取决于: org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.50
那么我的下一个问题是:这些人是罪魁祸首吗?如果是这样,我如何安全地删除它们?

我有完全相同的stacktrace,并通过添加slf4j log4j桥来解决它,以确保所有仍然依赖log4j的可传递或插件现在都将通过logback登录:

runtime "org.slf4j:jul-to-slf4j:1.7.7"
runtime "org.slf4j:log4j-over-slf4j:1.7.7"

希望能有所帮助。

不确定这是否有助于临时解决方案的运行mavenRepo感谢@vahid+1-但这并不是因为我找不到logback jar,而是因为我安装了logback转换,Log4j已经从我的Grails应用程序中删除,不知何故,我的Grails应用程序中的某些部分仍然依赖于Log4j。很抱歉,造成误解,我会尝试做一些事情1做一个依赖性报告,看看是否有其他插件正在尝试使用log4j-如果有,然后尝试从buildConfig中的插件调用中排除log4。。我还想尝试做的另一件事是做一个基本的vanilla grails应用程序,除了这个插件之外什么都不做,看看它是否发生在一个新创建的应用程序上,或者它是否与上面导致问题的另一个插件相关。。。。对不起,我可以;再次感谢@vahid+1-请查看我的更新,其中包括运行依赖关系报告。关于我应该从这里做什么,有什么想法吗?通常在一个定义好的插件中添加compile“:something:0.1',{excludes='something'}但是在这种情况下,这里可能会找到另一个替代方法,这是另一个可能有用的链接,以及关于如何排除内容的q
+--- org.grails.plugins:tomcat:7.0.54
|    \--- org.apache.tomcat:tomcat-catalina-ant:7.0.53
|    \--- org.apache.tomcat.embed:tomcat-embed-jasper:7.0.53
|         \--- org.apache.tomcat.embed:tomcat-embed-el:7.0.53

<HERE>
|    \--- org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.53

+--- org.grails:grails-plugin-rest:2.4.2
|    \--- org.slf4j:jcl-over-slf4j:1.7.5
|    \--- org.slf4j:slf4j-api:1.7.5
|    \--- com.google.code.gson:gson:2.2.4
|    \--- org.grails:grails-web:2.4.2
|         \--- org.grails:grails-web-common:2.4.2
|              \--- org.springframework:spring-webmvc:4.0.5.RELEASE
|              \--- org.springframework:spring-context-support:4.0.5.RELEASE
|              \--- org.grails:grails-databinding:2.4.2
|         \--- org.grails:grails-web-url-mappings:2.4.2
|         \--- org.grails:grails-web-fileupload:2.4.2
|              \--- commons-fileupload:commons-fileupload:1.3.1
|                   \--- commons-io:commons-io:2.2
|         \--- org.grails:grails-web-gsp:2.4.2
|         \--- org.springframework:spring-aspects:4.0.5.RELEASE
|         \--- org.grails:grails-web-mvc:2.4.2
|         \--- org.grails:grails-web-sitemesh:2.4.2
|              \--- opensymphony:sitemesh:2.4
|         \--- org.grails:grails-web-databinding:2.4.2
|         \--- org.grails:grails-web-jsp:2.4.2
|         \--- org.aspectj:aspectjweaver:1.8.0
|         \--- org.aspectj:aspectjrt:1.8.0
|    \--- org.grails:grails-plugin-controllers:2.4.2
|         \--- org.grails:grails-plugin-validation:2.4.2
|    \--- org.grails:grails-plugin-datasource:2.4.2
|         \--- org.springframework:spring-jdbc:4.0.5.RELEASE

<HERE>
|         \--- org.apache.tomcat.embed:tomcat-embed-logging-log4j:7.0.50
runtime "org.slf4j:jul-to-slf4j:1.7.7"
runtime "org.slf4j:log4j-over-slf4j:1.7.7"