How to log Hibernate SQL in to log file?

It is important to log the hibernate sql into log file for debugging purpose.

For this, we need to add a special logger/category named “org.hibernate.SQL” set to “DEBUG” option in log4j.xml

<logger name="org.hibernate.SQL" additivity="false">
    <level value="DEBUG" />
    <appender-ref ref="<LOG_APPENDER>" />


<category name="org.hibernate.SQL" additivity="false">
    <priority value="debug"/>
    <appender-ref ref="<LOG_APPENDER>" />

Additivity denotes whether the log needs to be added into the parent logger or not.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: