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.<level value="OFF"/>
</logger>
<logger name="org.springframework">
<level value="OFF"/>
</logger>
<logger name="org.apache.commons">
<level value="OFF"/>
</logger>
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
log4j.logger.org.springframework=OFF
log4j.logger.org.apache.commons=OFF
click here for sample log4j.xml
Thank you very much for the post. =D
ReplyDeletekeep up the good work