top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to integrate log4j logging in hibernate application?

+1 vote
400 views
How to integrate log4j logging in hibernate application?
posted May 10, 2016 by Dominic

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Hibernate 4 uses JBoss logging rather than slf4j used in earlier versions. For log4j configuration, we need to follow below steps.

Add log4j dependencies for maven project, if not maven then add corresponding jar files.

Create log4j.xml configuration file or log4j.properties file and keep it in the classpath. You can keep file name whatever you want because we will load it in next step.

For standalone projects, use static block to configure log4j using DOMConfigurator or PropertyConfigurator. For web applications, you can use ServletContextListener to configure it.

That’s it, our setup is ready. Create org.apache.log4j.Logger instance in the java classes and start logging

answer May 20, 2016 by Karthick.c
...