Thursday, February 05, 2009
How to get Hibernate parameter bindings and ONLY parameter bindings
With that out of the way, if you search around with Google and look for information on how to get the parameter bindings for SQL statements executed by Hibernate (which brilliantly are not given if you turn on SQL logging; see also: "mule shit"), you'll see a lot of smartass answers like setting
org.hibernate.types=debugin your log4j configuration.
While that configuration change does include the parameter bindings, it also includes a giant shit-pile (mule) of extra data that you probably couldn't possibly care less about, including every time Hibernate binds a return value to a type. These different messages cannot be immediately differentiated by severity or by type (see also: "gimpy").
There is a mostly-workable solution, provided Hibernate has implemented/continues to implement their debugging messages in a consistent fashion:
<appender name="SQLparams" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="TRACE"/>
<param name="ConversionPattern" value="%d %-5p [%c] - %m%n"/>
<param name="StringToMatch" value=" to parameter: " />
<param name="AcceptOnMatch" value="true" />
<filter class="org.apache.log4j.varia.DenyAllFilter" />
<appender-ref ref="SQLparams" />
This filters the log4j output of org.hibernate.type.*, including only the lines that contain the text " to parameter: ". This will of course also include constants coming back from your database that include the phrase " to parameter: ", but chances are this will usually be good enough, unless or until Hibernate pries its overinflated head out of its ass.
Thursday, April 26, 2007
Missing Logging in Wicket
The problem turned out to be that although my development container is Tomcat, which uses log4j for its logging and consequently configures a log4j root logger and appender, my deployment container is Resin Opensource, which does not.
The answer was to create a log4j.properties file in src/main/resources (so it is automatically included in the .war by Maven 2) with this in it:
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
Now my logging goes to stdout and is happily recorded by Resin.
Now if I could just get somewhere with WICKET-506.
Subscribe to Posts [Atom]