开发者

NHibernate - see SQL without all the other guff

开发者 https://www.devze.com 2023-01-07 11:14 出处:网络
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 D

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消