I add Security problems in may Spring application so I wanted to debug Spring thru log4j
.
Log4j
is working because my services are logging debug information to the console.
But Spring does not log anything to my console
Here is my log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CA" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM/dd/yy - HH\:mm\:ss,SSS} [%t] %-5p %c %x - %m%n" />
</layout>
</appender>
<logger name="org.springframework" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="CA"/>
</logger>
<logger name="com.test" additivity="false">
<level value="INFO"/>
<appender-ref ref="CA"/>
</logger>
</log4j:configuration>
It is well taken into consideration as I so putting --Dlog4j.debug
in my server start options. Result :
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: org.apache.xerces.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.springframework] additivity to [false].
log4j: Level value for org.springframework is [DEBUG].
log4j: org.springframework level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{MM/dd/yy - HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n].
log4j: Adding appender named [CA] to category [org.springframework].
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [com.test] additivity to [false].
log4j: Level value for com.testis [INFO].
log4j: com.testlevel set to INFO
log4j: Adding appender named [CA] to category [com.test].
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: org.apache.xerces.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.springframework] additivity to [false].
log4j: Level value for org.springframework is [DEBUG].
log4j: org.springframework level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{MM/dd/yy - HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n].
log4j: Adding appender named [CA] to category [org.springframework].
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [com.test] additivity to [false].
log4j: Level value for com.test is [INFO].
log4j: com.test level set to INFO
log4j: Adding appender named [CA] to category [com.test].
I try to add this in my web.xml as said in this question
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
I used this debug in other application and I really didn't see the cause... Thanks for your help