So I'm 开发者_JAVA百科using log4net to write log output to the trace. Show sql is specified in the configuration file. I seem to have to set the log output level to DEBUG to get the SQL output, but DEBUG also produces pages and pages of other guff I have to scroll past.
Can I get the SQL without the guff?
Thanks
David
You can add a logger for NHibernate.SQL
in the log4net
config block, like so:
<logger name="NHibernate.SQL" additivity="false">
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</logger>
With the appender-config
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date - %message%newline"/>
</layout>
</appender>
(replace this with whatever you prefer, like rollingFileAppender
)
Another option is using a tool like NHibernate Profiler.
精彩评论