Pages

Showing posts with label hibernate. Show all posts
Showing posts with label hibernate. Show all posts

Wednesday, 19 June 2013

log4j stop or disable adding spring and hibernate logs in your applications log files

Configuring log4j in spring or hibernate using maven is very simple.We just need to create and add the log4j.xml or log4j.properties file in resources folder.

After adding log4j.xml  logging was successfully. But when I checked the log files I found that spring,hibernate debug logs and  info logs are getting written in my applications log files.To avoid or alter this we can configure spring ,hibernate or other logging mechanisms as below :

In log4j.xml if we add below lines it will disable a spring and hibernate logging in your application log:

<logger name="org.hibernate">
  <level value="OFF"/>
</logger>
<logger name="org.springframework">
  <level value="OFF"/>
</logger>
<logger name="org.apache.commons">
  <level value="OFF"/>
</logger>


In above example you can set the levels to DEBUG,ERROR,INFO,ALL,OFF,FATAL.
Note*: It would be more better to add ERROR level instead of OFF as it will show exception log.

Example for log4j.properties is below :

log4j.logger.org.hibernate=OFF
log4j.logger.org.springframework=OFF
log4j.logger.org.apache.commons=OFF


click here for sample log4j.xml

If you found this post useful. Please share and comment. Thanks :)