Configure Logging Hibernate

Configure Logging Hibernate

Summary: To configure logging in hibernate you need to have available in class path and below dependency in your pom.xml file.

  • file:
# Log messages to log file
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Write output to console as stdout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Root logger option
log4j.rootLogger=INFO, file, stdout
# Log DEBUG level
# Log JDBC parameters
  • pom.xml file dependency:


  • If you are using eclipse project include slf4j-log4j12.jar in your class path.

Step 1: This demo is extension of this tutorial just you need file in src/main/resources folder and run it.

Step 2: Below is final project structure:

Configure Logging Hibernate


Step 3: To run test class right click –> Run As –> Java Application . You will see below full log

details on console:

Configure Logging Hibernate

Step 4: Now open log file you will see details as below:

Configure Logging Hibernate

download2 Download project:  HibernateAnnotationExample

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *