jeudi 24 septembre 2015

Can't stop NHibernate from writing log to console in unit tests

I have some unit tests that work with nhibernate on a local database.

I do not always need the show_sql output, so mostly I want to deactivate it. But no matter how I set the property, either in the App.config of the test project

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
        <property name="connection.connection_string_name">test</property>
        <property name="show_sql">false</property>
        <mapping assembly="MyLib"/>
    </session-factory>
</hibernate-configuration>

Or via the configuration in the test classes

_logger.Info("Configuring NHibernate");
_configuration = new Configuration().Configure();
_configuration.SetProperty("nhibernate.show_sql", "false");
_sessionFactory = _configuration.BuildSessionFactory();

The console output always shows the SQL statements, cluttering up the console.

What am I missing? Do I set the value wrong?

Aucun commentaire:

Enregistrer un commentaire