4

EDIT:

The question that is marked as being a duplicate of my question does not provide the answer. That answer tells me how to ensure that commons-logging is logging to log4j, and how to ensure that the correct log4j.xml file is being utilised. As per my comment at the end of this question, I have successfully ensured that I am using log4j, and that I am using the correct log4j.xml file. Please remove the flag which marks this question as a duplicate.

END EDIT:

I am attempting to turn off all the debug logging statements that spring sends to the console.

Trying the following does not work:

  <logger name="org.springframework">
    <level value="warn"></level>
    <appender-ref ref="console" /> 
  </logger>

  <root> 
    <priority value ="debug" /> 
    <appender-ref ref="console" /> 
  </root>

However just changing root to warn does work, and I no longer see the debug statements as required. But this doesn't feel like a very clean solution to me.

  <root> 
    <priority value ="warn" /> 
    <appender-ref ref="console" /> 
  </root>

Changing the logger name to the below doesn't work either:

<logger name="log4j.category.org.springframework">

Here is my entire log4j.xml file. We're using log4j2 for the rest of our logging

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
     <appender name="console" 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> 

  <logger name="org.springframework">
    <level value="warn"></level>
    <appender-ref ref="console" /> 
  </logger>

  <root> 
    <priority value ="debug" /> 
    <appender-ref ref="console" /> 
  </root>
</log4j:configuration>
James Hutchinson
  • 841
  • 2
  • 13
  • 27
  • remove `log4j.category` from the logger name. – M. Deinum May 07 '15 at 12:02
  • The answer to the suggested duplicate informs the user how to ensure that the correct log4j.xml file is being used. I have looked at that answer, and am satisfied that I am using the correct file. Indeed I can modify the root element of my file to disable debug statements, but I'm not happy with that approach, and would prefer a better way – James Hutchinson May 07 '15 at 13:25
  • Also, I have tried to remove log4j.category from the logger name, and that doesn't work either. – James Hutchinson May 07 '15 at 13:25

0 Answers0