David
David

Reputation: 16120

NHibernate - see SQL without all the other guff

So I'm 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

Upvotes: 0

Views: 168

Answers (1)

tijmenvdk
tijmenvdk

Reputation: 1758

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.

Upvotes: 3

Related Questions