NHibernate +流利的映射+ NLog =在程序集中找不到映射的文档 [英] NHibernate + fluent mapping + NLog = No mapped documents found in assembly

查看:106
本文介绍了NHibernate +流利的映射+ NLog =在程序集中找不到映射的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于先前使用hbm.xml文件的项目,我已经成功地使用NHibernate中的CommonLogging层通过NLog记录了其内部消息.我现在切换到流利的映射,并且NHibernate日志现在仅包含一行:

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>

配置映射后,我还尝试将nhibernate-logger配置指令从App.config文件移动到代码中,并且收到与以前相同的警告:

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);

我在做什么错了?

推荐答案

好的,我对此感到很尴尬,我很想完全删除该问题,但是我决定发布解决方案,以防万一其他空头遇到了同样的问题:我忘记从NLog配置中删除minLevel指令,而我只记录警告,错误和致命错误–该警告使我认为由于警告而我没有在记录日志,而在事实不是因为我禁止了较低级别的消息而记录日志.

Ok, I'm quite embarrassed by this, and I was tempted to delete the question altogether, but I decided to post the solution just in case some other airhead hits the same snag: I had forgotten to remove the minLevel directive from the NLog configuration, and I was only logging warnings, errors and fatal errors – and that warning made me think it wasn't logging because of the warning, when in fact it wasn't logging because I had inhibited lower level messages.

这篇关于NHibernate +流利的映射+ NLog =在程序集中找不到映射的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆