Javatpoint Logo
Javatpoint Logo

Hibernate Logging by Log4j using properties file

As we know, Log4j and Logback frameworks are used to support logging in hibernate, there are two ways to perform logging using log4j:

  1. By log4j.xml file (or)
  2. By log4j.properties file

Here, we are going to enable logging using log4j through properties file.


Steps to perform Hibernate Logging by Log4j using properties file

There are two ways to perform logging using log4j using properties file:

  1. Load the log4j jar files with hibernate
  2. Create the log4j.properties file inside the src folder (parallel with hibernate.cfg.xml file)

Example of Hibernate Logging by Log4j using properties file

You can enable logging in hibernate by following only two steps in any hibernate example. This is the first example of hibernate application with logging support using log4j.

Load the required jar files

You need to load the slf4j.jar and log4j.jar files with hibernate jar files.

download all the required jar files

Create log4j.properties file

Now you need to create log4j.properties file. In this example, all the log details will be written in the C:\\javatpointhibernate.log file.

log4j.properties





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA