spring框架卡在调试日志级别上 [英] spring framework stuck on debug log level

查看:146
本文介绍了spring框架卡在调试日志级别上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过log4j.xml配置spring框架日志记录级别。我的文件如下所示:

I'm trying to configure spring framework logging level via log4j.xml. My file looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<!-- <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> -->
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Create a console appender -->
    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <param name="threshold" value="debug" />
        <param name="Target" value="System.out" />
        <param name="ImmediateFlush" value="true" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %-45.45c: %m%n" />
        </layout>
    </appender>

    <!-- Change the logging of some known libraries, no need for most of the 
        chatter -->
    <category name="org.apache">
        <priority value="ERROR" />
    </category>
    <category name="org.springframework">
        <priority value="ERROR" />
    </category>
    <category name="org.springframework.data">
        <priority value="INFO" />
    </category>
    <category name="com.mchange">
        <priority value="INFO" />
    </category>

    <!-- <category name="com.ssv.mq.service"> <priority value="INFO"/> </category> -->

    <category name="com.ro">
        <priority value="INFO" />
    </category>


    <!-- Perhaps add some extra logging for org.springframework.jdbc.core -->
    <category name="org.springframework.jdbc.core">
        <priority value="INFO" />
    </category>

    <!-- Setup the root logger -->
    <root>
        <priority value="INFO"></priority>
<!--        <appender-ref ref="EMAIL_ASYNC" />  -->
        <appender-ref ref="CONSOLE"/>
    </root>
</configuration>

但是,spring正在记录调试信息,这里是catalina.out的示例:

However, spring is logging debug info all over, here is a sample of catalina.out:

15:46:03.535 [http-bio-8080-exec-3] DEBUG o.s.s.w.u.m.AntPathRequestMatcher - Checking match of request : '/oauth/token'; against '/oauth/cache_approvals' 
15:46:03.536 [http-bio-8080-exec-3] DEBUG o.s.s.w.u.m.AntPathRequestMatcher -     Checking match of request : '/oauth/token'; against '/oauth/uncache_approvals' 
15:46:03.536 [http-bio-8080-exec-3] DEBUG o.s.s.w.u.m.AntPathRequestMatcher - Checking match of request : '/oauth/token'; against '/oauth/token' 
15:46:03.536 [http-bio-8080-exec-3] DEBUG o.s.security.web.FilterChainProxy -
 /oauth/token?grant_type=password&client_id=my-trusted-client-with-secret&client_secret=somesecret&username=seema&password=jrd@123456 at position 1 of 7 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'

请注意我不是那么多的弹簧专家所以它可能是像maven(slf4j或其他)中缺少某些依赖项一样简单。

Please note that i'm not that much of a spring expert so it might be something as simple as some missing dependencies in maven (slf4j or something).

我确信log4j.xml位于正确的位置并且从春天开始加载。

What i'm sure of is that log4j.xml is in the correct location and that it gets loaded from spring.

编辑:

I added the debug flags as suggested by stephane and here is the output:
  delegate: false^M
  repositories:^M
    /WEB-INF/classes/^M
----------> Parent Classloader:^M
org.apache.catalina.loader.StandardClassLoader@69fc49ef^M
.
log4j: Using URL [file:/var/lib/tomcat7/webapps/propspace-api/WEB-INF/classes/log4j.xml] for automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
log4j: debug attribute= "null".
log4j: Ignoring debug attribute.
log4j: reset attribute= "false".
log4j: Threshold ="null".
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.apache] additivity to [true].
log4j: Level value for org.apache is  [ERROR].
log4j: org.apache level set to ERROR
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.springframework] additivity to [true].
log4j: Level value for org.springframework is  [ERROR].
log4j: org.springframework level set to ERROR
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.springframework.data] additivity to [true].
log4j: Level value for org.springframework.data is  [ERROR].
log4j: org.springframework.data level set to ERROR
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.springframework.jdbc.core] additivity to [true].
log4j: Level value for org.springframework.jdbc.core is  [WARN].
log4j: org.springframework.jdbc.core level set to WARN
log4j: Level value for root is  [WARN].
log4j: root level set to WARN
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Setting property [threshold] to [DEBUG].
log4j: Setting property [target] to [System.out].


`So far so good, but two lines later, i'm still getting the spring debug messages:
`17:26:00.630 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.security.methodSecurityMetadataSourceAdvisor'
17:26:00.630 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
`


推荐答案

谢谢Stephane,
这篇文章实际上引导我将依赖项排除在logback和jcl-over-slf4j之外。现在它工作正常。

Thanks Stephane, This post Actually guided me to exclude the dependencies to logback and jcl-over-slf4j. Now it's working fine.

这篇关于spring框架卡在调试日志级别上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆