Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling logging in Spring

Tags:

java

spring

log4j

We are using RAD 7.5 as IDE and also log4j for logging purpose. we want to enable spring logging.

I tried the following

  • Added org.springframework.web.util.Log4jConfigListener as a listener in web.xml. It is added before ContextLoaderListener.
  • log4j.properties is present in application war under WEB-INF.
  • Add the following context parameter in web.xml:

<context-param>
  <param-name>log4jConfigLocation</param-name>
  <param-value>/WEB-INF/log4j.properties</param-value>
</context-param>

In log 4j added the following

log4j.logger.org.springframework=ALL

Even then I am not able to see any output in console or in log file.

Can anyone please let me know the exact steps for enabling spring logging.

like image 976
KUCH Avatar asked Jun 24 '11 14:06

KUCH


2 Answers

If you're using log4j2 using the common XML configuration format, add a Logger in your Loggers node:

<Logger name="org.springframework" level="trace"/>

Normally, the appenders used will be the ones attached to the Root entry.

like image 58
Nick Avatar answered Oct 17 '22 07:10

Nick


In your properties file you should have

log4j.category.org.springframework=ALL

not

log4j.logger.org.springframework=ALL

See this section in the Spring reference.

like image 43
Paul Avatar answered Oct 17 '22 06:10

Paul