Skip to main content


Showing posts with the label log4j

Java - How to print Hibernate query parameters on console?

Introduction In this post, we will learn how to print Hibernate Query parameters using log4j. Requirments log4j-api-2.13.1.jar log4j-core-2.13.1.jar Step 1 Place the above two log4j jars inside the lib directory. For web applications, the lib directory is located inside the WEB-INF folder. Step 2 Create a file by the name of  log4j2.xml and place it inside your src folder. Step 3 Place the following XML code inside the  log4j2.xml file <configuration status="WARN"> <appenders> <console name="LogToConsole" target="SYSTEM_OUT"> <patternlayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"> </patternlayout></console> </appenders> <loggers> <logger additivity="false" level="debug" name="org.myapp"> <appenderref ref="LogToConsole"> &