I haven’t been able to find any documentation on how to configure Hibernate’s logging using the XML style configuration file for Log4j.
Is this even possible or do I have use a properties style configuration file to control Hibernate’s logging?
If anyone has any information or links to documentation it would appreciated.
EDIT:
Just to clarify, I am looking for an example of the actual XML syntax to control Hibernate.
EDIT2:
Here is what I have in my XML config file.
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE log4j:configuration SYSTEM 'log4j.dtd'> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name='console' class='org.apache.log4j.ConsoleAppender'> <param name='Threshold' value='info'/> <param name='Target' value='System.out'/> <layout class='org.apache.log4j.PatternLayout'> <param name='ConversionPattern' value='%d{ABSOLUTE} [%t] %-5p %c{1} - %m%n'/> </layout> </appender> <appender name='rolling-file' class='org.apache.log4j.RollingFileAppender'> <param name='file' value='Program-Name.log'/> <param name='MaxFileSize' value='1000KB'/> <!-- Keep one backup file --> <param name='MaxBackupIndex' value='4'/> <layout class='org.apache.log4j.PatternLayout'> <param name='ConversionPattern' value='%d [%t] %-5p %l - %m%n'/> </layout> </appender> <root> <priority value ='debug' /> <appender-ref ref='console' /> <appender-ref ref='rolling-file' /> </root> </log4j:configuration>
Logging works fine but I am looking for a way to step down and control the hibernate logging in way that separate from my application level logging, as it currently is flooding my logs. I have found examples of using the preference file to do this, I was just wondering how I can do this in a XML file.
From http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-logging
Here’s the list of logger categories:
Formatted for pasting into a log4j XML configuration file:
NB: Most of the loggers use the DEBUG level, however org.hibernate.type uses TRACE. In previous versions of Hibernate org.hibernate.type also used DEBUG, but as of Hibernate 3 you must set the level to TRACE (or ALL) in order to see the JDBC parameter binding logging.
And a category is specified as such:
It must be placed before the root element.