Announcement Announcement Module
Collapse
No announcement yet.
Unable to disable spring logging message Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to disable spring logging message

    Dear all,

    I'm using RAD 7.0 with log4j 1.3 alpha8.

    Run following test case:

    package com.foo.transactionhistory.test;
    import java.util.List;
    import org.apache.log4j.FileAppender;
    import org.apache.log4j.Level;
    import org.apache.log4j.LogManager;
    import org.apache.log4j.Logger;
    import org.apache.log4j.SimpleLayout;
    import org.apache.log4j.joran.JoranConfigurator;

    import com.foo.test.IntegrationTest;
    public class TestLogging extends IntegrationTest {
    static Logger logger;

    public void testLog() {

    JoranConfigurator jc = new JoranConfigurator();
    jc.doConfigure("test/java/com/foo/transactionhistory/test/logging.xml",
    LogManager.getLoggerRepository());

    List errorList = jc.getErrorList();
    for (int i = 0; i < errorList.size(); i++) {
    System.out.println(errorList.get(i));
    }

    Logger logger = Logger.getLogger(this.getClass().getName());

    logger.info("Info...");
    logger.warn("Warn...");
    logger.fatal("Fatal...");
    logger.debug("Debug...");

    }
    }

    Logging.xml setting
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration>
    <!-- debug="true" -->
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="traceAppender"
    class="org.apache.log4j.FileAppender">
    <param name="File" value="C:/TEMP/trace.log" />
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern"
    value="[Time:%d][Level:%p]%m%n" />
    </layout>
    </appender>

    <appender name="debugAppender"
    class="org.apache.log4j.FileAppender">
    <param name="File" value="C:/TEMP/debug.log" />
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern"
    value="[Time:%d][Level:%p]%m%n" />
    </layout>
    </appender>

    <appender name="errorRecorderAppender"
    class="org.apache.log4j.FileAppender">
    <param name="File" value="C:/TEMP/errorRecorder.log" />
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern"
    value="[Time:%d][Level:%p]%m%n" />
    </layout>
    </appender>

    <appender name="consoleAppender"
    class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out" />
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%-5p %c{1} - %m%n" />
    </layout>
    </appender>

    <!-- autofile compression in each day -->
    <appender name="rollingFileAppender"
    class="org.apache.log4j.rolling.RollingFileAppende r">
    <rollingPolicy
    class="org.apache.log4j.rolling.TimeBasedRollingPo licy">
    <param name="FileNamePattern" value="C:/TEMP/error.%d.gz" />
    </rollingPolicy>

    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%c{1} - %m%n" />
    </layout>
    </appender>



    <logger name="com.foo" additivity="false">
    <level value="INFO" />
    <appender-ref ref="debugAppender" />
    <appender-ref ref="errorRecorderAppender" />
    <appender-ref ref="consoleAppender" />
    <appender-ref ref="rollingFileAppender" />
    </logger>

    <logger name="org.springframework" additivity="false">
    <level value="OFF"/>
    </logger>


    <!-- this part is not working, if the above is defined -->
    <root>
    <level value="WARN" />
    </root>

    </log4j:configuration>


    Following is output in Console


    Nov 7, 2007 2:08:33 PM org.springframework.test.AbstractSingleSpringConte xtTests loadContextLocations
    INFO: Loading context for locations: classpath:unit-test-beans-config.xml
    Nov 7, 2007 2:08:33 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [unit-test-beans-config.xml]
    Nov 7, 2007 2:08:33 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [persistence/dao.xml]
    Nov 7, 2007 2:08:34 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [service/services.xml]
    Nov 7, 2007 2:08:34 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [unit-test-hibernate.xml]
    Nov 7, 2007 2:08:34 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [persistence/hibernate.xml]
    Nov 7, 2007 2:08:34 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory registerBeanDefinition
    INFO: Overriding bean definition for bean 'propertyConfigurer': replacing [Root bean: class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [unit-test-hibernate.xml]] with [Root bean: class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [persistence/hibernate.xml]]
    Nov 7, 2007 2:08:34 PM org.springframework.context.support.AbstractApplic ationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.GenericApplica tionContext@40bc40bc: display name [org.springframework.context.support.GenericApplica tionContext@40bc40bc]; startup date [Wed Nov 07 14:08:34 CST 2007]; root of context hierarchy
    Nov 7, 2007 2:08:34 PM org.springframework.context.support.AbstractApplic ationContext obtainFreshBeanFactory
    INFO: Bean factory for application context [org.springframework.context.support.GenericApplica tionContext@40bc40bc]: org.springframework.beans.factory.support.DefaultL istableBeanFactory@58425842
    Nov 7, 2007 2:08:34 PM org.springframework.core.io.support.PropertiesLoad erSupport loadProperties
    INFO: Loading properties file from class path resource [persistence/jdbc.properties]
    Nov 7, 2007 2:08:34 PM org.springframework.context.support.AbstractApplic ationContext$BeanPostProcessorChecker postProcessAfterInitialization
    INFO: Bean 'org.springframework.aop.config.internalAutoProxyC reator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    :
    :
    INFO: Not binding factory to JNDI, no JNDI name configured
    Nov 7, 2007 2:08:40 PM org.springframework.orm.hibernate3.HibernateTransa ctionManager afterPropertiesSet
    INFO: Using DataSource [org.apache.commons.dbcp.BasicDataSource@6dec6dec] of Hibernate SessionFactory for HibernateTransactionManager
    Setup success
    Nov 7, 2007 2:08:41 PM org.springframework.test.AbstractTransactionalSpri ngContextTests startNewTransaction
    INFO: Began transaction (1): transaction manager [org.springframework.orm.hibernate3.HibernateTransa ctionManager@4c524c52]; default rollback = true

    INFO TestLogging - Info...
    WARN TestLogging - Warn...
    FATAL TestLogging - Fatal...
    Nov 7, 2007 2:08:41 PM org.springframework.test.AbstractTransactionalSpri ngContextTests endTransaction
    INFO: Rolled back transaction after test execution


    Here's the questions:
    1. I've tried to disable springframework console log (red color in the above) by setting in logging.xml
    <logger name="org.springframework" additivity="false">
    <level value="OFF"/>
    </logger>

    But the setting doesn't work. The console logging is the same as logging without above setting. Any suggestions on why it's not working?

    2. Is it correct to set the logging.xml in program, using JoranConfigurator? Any other way to configure logging.xml file in RAD 7.0?

    Thanks a lot.
Working...
X