I've successfully used the CommonLogging layer in NHibernate to log its internal messages using NLog for previous projects which were using hbm.xml files. I'm now switching to fluent mapping, and the NHibernate logs now only contain one line:
[Log entry: Warn] 2019-02-01 13:30:42.5537 No mapped documents found in assembly: <assembly name>
I also tried to move the nhibernate-logger
configuration directive from the App.config
file to the code, just after configuring the mapping – and I'm receiving the same warning as before:
var dbCfg = new Configuration();
dbCfg.Configure();
dbCfg = Fluently.Configure(dbCfg)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<RetailerMapping>())
.ExposeConfiguration(c =>
{
c.SetProperty(@"nhibernate-logger", @"NHibernate.Logging.CommonLogging.CommonLoggingLoggerFactory, NHibernate.Logging.CommonLogging");
})
.BuildConfiguration();
dbCfg.AddAssembly(Assembly.GetExecutingAssembly().GetName().Name);
What am I doing wrong?