I use log4j2
and I can't get logging from spring.
when I write my own logger.debug(...);
it works but it's the same as System.out.println(...);
.
I want to know what happened behind the scenes in spring. show the created bean or debuggig error like 400 ...
I try this Conf but nothing happened :
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="ALL">
<AppenderRef ref="CONSOLE"/>
</Root>
<logger name="org.springframework" level="ALL">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver" level="ALL">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.beans.factory.support.DefaultListableBeanFactory" level="ALL">
<appender-ref ref="CONSOLE"/>
</logger>
</Loggers>
</Configuration>
pom.xml
<!-- log4j2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-rc2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-rc2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.0-rc2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.0-rc2</version>
</dependency>
Startup log :
juil. 09, 2014 4:42:57 PM org.apache.catalina.core.AprLifecycleListener init
Infos: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Broadcom\Broadcom 802.11\Driver;D:\apache-maven-3.1.1\bin;C:\wamp\bin\mysql\mysql5.5.24\bin;C:\Program Files\Java\jdk1.7.0_45\bin;;D:\AO Project\eclipse;;.
juil. 09, 2014 4:42:57 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
Avertissement: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:AO' did not find a matching property.
juil. 09, 2014 4:42:57 PM org.apache.coyote.AbstractProtocol init
Infos: Initializing ProtocolHandler ["http-nio-8080"]
juil. 09, 2014 4:42:57 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
Infos: Using a shared selector for servlet write/read
juil. 09, 2014 4:42:57 PM org.apache.coyote.AbstractProtocol init
Infos: Initializing ProtocolHandler ["ajp-nio-8009"]
juil. 09, 2014 4:42:57 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
Infos: Using a shared selector for servlet write/read
juil. 09, 2014 4:42:57 PM org.apache.catalina.startup.Catalina load
Infos: Initialization processed in 670 ms
juil. 09, 2014 4:42:57 PM org.apache.catalina.core.StandardService startInternal
Infos: Démarrage du service Catalina
juil. 09, 2014 4:42:57 PM org.apache.catalina.core.StandardEngine startInternal
Infos: Starting Servlet Engine: Apache Tomcat/8.0.9
juil. 09, 2014 4:43:02 PM org.apache.catalina.core.ApplicationContext log
Infos: Log4jServletContainerInitializer starting up Log4j in Servlet 3.0+ environment.
juil. 09, 2014 4:43:03 PM org.apache.catalina.core.ApplicationContext log
Infos: No Spring WebApplicationInitializer types detected on classpath
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
juil. 09, 2014 4:43:03 PM org.apache.catalina.core.ApplicationContext log
Infos: Initializing Spring root WebApplicationContext
juil. 09, 2014 4:43:04 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [
name: persistenceYous
...]
juil. 09, 2014 4:43:05 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.5.Final}
juil. 09, 2014 4:43:05 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
juil. 09, 2014 4:43:05 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
juil. 09, 2014 4:43:06 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
juil. 09, 2014 4:43:06 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
juil. 09, 2014 4:43:07 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
juil. 09, 2014 4:43:11 PM org.apache.catalina.core.ApplicationContext log
Infos: Log4jServletContextListener ensuring that Log4j starts up properly.
juil. 09, 2014 4:43:11 PM org.apache.catalina.core.ApplicationContext log
Infos: Log4jServletFilter initialized.
juil. 09, 2014 4:43:11 PM org.apache.catalina.core.ApplicationContext log
Infos: Initializing Spring FrameworkServlet 'mvc-dispatcher'
juil. 09, 2014 4:43:13 PM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["http-nio-8080"]
juil. 09, 2014 4:43:13 PM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["ajp-nio-8009"]
juil. 09, 2014 4:43:13 PM org.apache.catalina.startup.Catalina start
Infos: Server startup in 15715 ms
The problem is solved I think the error come from this
I have to route logs from
slf4j
tolog4j
because i thinkSpring
useslf4j
for logging So i addlog4j-slf4j-impl
jar and FINALLY it works :-)PS : Why i think
Spring
useslf4j
instead ofcommon logging
because i addlog4j-jcl
jar but nothing happened .