2

I have programmatically create log4net log from config file:

var properties = new NameValueCollection
            {
                {"configType", "FILE"},
                {"configFile", @"c:/log4net.config"}
            };
Common.Logging.LogManager.Adapter = new Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter(properties);

This is my log4net.config (EDITED for simplicity as dove suggested) :

<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <file value="c:/log.log" />
    <appendToFile value="true" />
    <maximumFileSize value="100KB" />
    <maxSizeRollBackups value="5" />

    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%d [%t] %-5p %c - %m%n" />
    </layout>
</appender>

<root>
    <level value="All" />
    <appender-ref ref="RollingFile" />  
</root> 
<logger name="NHibernate">
    <level value="All" />
    <appender-ref ref="RollingFile" />
</logger>       

</log4net>

I got Spring.NET successfuly logging into that file, but not NHibernate. Nhibernate is configured fluenltly:

protected override void PostProcessConfiguration(Configuration config)
{           
    base.PostProcessConfiguration(config);
        var msSqlCfg = MsSqlConfiguration.MsSql2000.ConnectionString(ConnectionString)
            .ShowSql();

        Fluently.Configure(config).Database(msSqlCfg)
                .Mappings(m => m.FluentMappings.Add<EmployeeMap>())
                // Other mappings            
                .BuildSessionFactory();
    }

What should I fix to get Nhibernate log working?

dbardakov
  • 651
  • 1
  • 8
  • 22

1 Answers1

2

Does it log if you generate statistics?

Configuration.ExposeConfiguration(c => 
            c.SetProperty("generate_statistics", "true"));

To narrow things down can you remove additivity flag and appeder from within logger and just log one to start, i.e. exactly like this

<logger name="NHibernate">
  <level value="ALL" />
</logger>
dove
  • 20,469
  • 14
  • 82
  • 108
  • Could it be related to Ms Sql Server edition? I have 2008R2 Express. – dbardakov Sep 02 '13 at 05:34
  • Tried NHTrace with no result (still empty SLQ log) – dbardakov Sep 03 '13 at 08:25
  • possibly to do with Express, what nhibernate config settings are you using for that? check http://stackoverflow.com/questions/9495525/how-connect-nhibernate-to-local-sqlexpress to make sure you've correct dialect and driver – dove Sep 03 '13 at 09:06