Announcement Announcement Module
Collapse
No announcement yet.
log4j: can't set spring log level separate from app log level Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • log4j: can't set spring log level separate from app log level

    I'm having trouble configuring my application log level separate from the spring log level. If I set my app log level to "debug" and the spring log level to "info", I get debug level logging from spring - not what I want. Interestingly, if I set spring log level to debug and app log level to info, I get what I expect, spring debug level logging and only app info level logging. In other apps, I've been able to set log levels selectively without any problems so I'm wondering if this is a spring related problem. My log4j.properties with <app logging>=debug and <spring logging>=info. As stated, with these settings, I'm getting spring debug logging. Any help would be immensely appreciated. I've spent way to much time on this!! Thanks, Chuck
    Code:
    log4j.rootLogger=INFO, FileAppender, ConsoleAppender
    
    #use this to control springframework logging
    log4j.logger.org.springframework=INFO
    #use this to control Settlements logging
    log4j.logger.com.embarq.tnt=DEBUG
    
    ########## Appender FileAppender
    log4j.appender.FileAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.FileAppender.File=c:/cellmaniaFiles/log/cellmaniaLog.log
    # Roll the log file at a certain time
    log4j.appender.FileAppender.DatePattern='.'yyyy-MM-dd
    # Append to the end of the file or overwrites the file at start.
    log4j.appender.FileAppender.Append=true
    log4j.appender.FileAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.FileAppender.layout.ConversionPattern=[%5p] %d{MM/dd/yy HH:mm:ss} <%C:%M():%L>: %n    %m%n%n
    
    ########## Appender ConsoleAppender
    log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
    log4j.appender.ConsoleAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.ConsoleAppender.layout.ConversionPattern=[%5p] %d{MM/dd/yy HH:mm:ss} <%C:%M():%L>: %n    %m%n%n

  • #2
    This configuration works for me; this is for my unit tests; the root level is at debug and spring is at info. (I hate log4j's properties file format and use the xml format instead, which I find a lot easier to understand and tweak. This file is named log4j.xml.)
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
        <appender name="CONS" class="org.apache.log4j.ConsoleAppender">
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%p: %C.%M: %m%n" />
            </layout>
        </appender>
    
        <!-- param entries must come before layout entry.            -->
        <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
            <param name="File" value="/tmp/cars.log" />
            <param name="MaxFileSize" value="300kb" />
            <param name="MaxBackupIndex" value="9" />
    
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%p: %d [%C %M] %m%n" />
            </layout>
        </appender>
    
        <logger name="org.springframework">
            <level value="info" />
            
            <appender-ref ref="CONS" />
            <appender-ref ref="FILE" />
        </logger>
    
        <root>
            <level value="debug" />
    
            <appender-ref ref="CONS" />
            <appender-ref ref="FILE" />
        </root>
    </log4j:configuration>
    Last edited by lumpynose; Sep 11th, 2007, 03:37 PM.

    Comment


    • #3
      log4j.logger.org.springframework=INFO, ConsoleAppender, FileAppender
      log4j.additivity.org.springframework=false

      Comment


      • #4
        I've reduced the scope of the problem, i.e. unwanted spring debug statements, to only debug output of the form:

        Code:
        [DEBUG] 09/13/07 15:38:37 <org.springframework.jdbc.object.RdbmsOperation:compile():321>: 
            RdbmsOperation with SQL [SELECT * FROM PRMSN ORDER BY PRMSN_NM] compiled
        With only this unwanted output, I tried al0's suggestion specifying:

        Code:
        og4j.logger.org.springframework=INFO, ConsoleAppender, FileAppender
        log4j.additivity.org.springframework=false
        But this had no effect. This unwanted output seems to originate from code fo the form:

        Code:
        class CodeSetByIdQuery extends MappingSqlQuery
        	{
        		CodeSetByIdQuery(DataSource ds, String inClause)
        		{
        			super(ds, "SELECT * FROM CODE_SET WHERE CODE_SET_ID IN (" + inClause + ")" + getDateClause());
        			compile();
        		}
        
        		protected Object mapRow(ResultSet rs, int rowNum) throws SQLException
        		{
        			return mapCodeSetRow(rs, rowNum);
        		}
        	}
        Any further pointers would be greatly appreciated. Thanks

        Comment


        • #5
          You have missed starting "l" at the 1st line
          Code:
          log4j.logger.org.springframework=INFO, ConsoleAppender, FileAppender
          log4j.additivity.org.springframework=false
          I do not no if it was done in your log4j.properties or only in post.
          If former, then it explains why it had no effect.

          Originally posted by ChuckAtEmbarq View Post
          I've reduced the scope of the problem, i.e. unwanted spring debug statements, to only debug output of the form:

          Code:
          [DEBUG] 09/13/07 15:38:37 <org.springframework.jdbc.object.RdbmsOperation:compile():321>: 
              RdbmsOperation with SQL [SELECT * FROM PRMSN ORDER BY PRMSN_NM] compiled
          With only this unwanted output, I tried al0's suggestion specifying:

          Code:
          og4j.logger.org.springframework=INFO, ConsoleAppender, FileAppender
          log4j.additivity.org.springframework=false
          But this had no effect. This unwanted output seems to originate from code fo the form:

          Code:
          class CodeSetByIdQuery extends MappingSqlQuery
          	{
          		CodeSetByIdQuery(DataSource ds, String inClause)
          		{
          			super(ds, "SELECT * FROM CODE_SET WHERE CODE_SET_ID IN (" + inClause + ")" + getDateClause());
          			compile();
          		}
          
          		protected Object mapRow(ResultSet rs, int rowNum) throws SQLException
          		{
          			return mapCodeSetRow(rs, rowNum);
          		}
          	}
          Any further pointers would be greatly appreciated. Thanks

          Comment

          Working...
          X