1

I have the following problem - it looks as if log4net is ignoring level in logger configuration when it comes to NHibernate.SQL and always logs on DEBUG.

If I change logger name to NHibernate it works fine and only messages above or equal to level are logged.

Here is my config:

<?xml version="1.0" encoding="utf-8" ?>
<log4net> 
  <appender name="console" type="log4net.Appender.ConsoleAppender">    
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="[%logger] %-5p %m%n" />
    </layout>
  </appender>
  <logger name="NHibernate.SQL" additivity="false">
    <level value="INFO" />
    <appender-ref ref="console" />
  </logger>
</log4net>

With this configuration I get following output:

[NHibernate.SQL] DEBUG Reading high value:select next_hi from hibernate_unique_key with (updlock, rowlock)
[NHibernate.SQL] DEBUG Updating high value:update hibernate_unique_key set next_hi = @p0 where next_hi = @p1;@p0 = 247 [Type: Int64 (0)], @p1 = 246 [Type: Int64 (0)]

NHibernate.config

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>

  <property name="connection.connection_string">XXX</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="show_sql">false</property>
    <property name="connection.release_mode">auto</property>
    <property name="adonet.batch_size">500</property>

  </session-factory>
</hibernate-configuration>
5
  • What is your app.config nhibernate configuration?
    – Peter
    Commented Oct 1, 2013 at 9:09
  • @peer: I've added my NHibernate.config
    – empi
    Commented Oct 1, 2013 at 9:13
  • Is that the whole log4net config? Do you have any other loggers configured? Where's the root logger? Commented Oct 1, 2013 at 12:45
  • @DanielSchilling: this is the simplest configuration that reproduces the problem.
    – empi
    Commented Oct 1, 2013 at 13:35
  • Maybe you should try enabling log4net debugging to see if anything jumps out at you. My only initial thought was that you had show_sql set to true in your nhibernate config because that will definitely cause this issue but from your config above it looks correct.
    – Cole W
    Commented Oct 1, 2013 at 17:36

1 Answer 1

2

The issue was that the code used NHibernate Profiler. Calling NHibernateProfiler.Initialize causes some loggers to be set do DEBUG level - in particular NHibernate.SQL.

I'm sorry I didn't give enough details - I'm using internal company framework and I wasn't aware of all the details.

Not the answer you're looking for? Browse other questions tagged or ask your own question.