Question

I'm having issues with some vague errors popping out of my fluent configuration. I have read that setting up a logging solution will help me zero in on the issue. I would like to use NLog. I understand that I need to use Common.Logging 2.0 and NHibernate.IInterfaceLogger to get it up and running. I'm just not sure how to put the pieces together. My system is based off of the Onion Architecture. I have my Logging service set up for NLog and I have my interface for it, but I'm just a bit confused on where I should bind all of this together. My Fluent NHibernate configuration exists in my Data project. I'm assuming I would want to bind all of this together there.

Any thoughts on this would be awesome! I'm a little lost!

Was it helpful?

Solution

NHibernate.NLog nuget package does this. I use it in a project now.

For the sake of completeness or if that package ever disappears or the user doesn't use nuget. You add this to your FluentConfiguration:

.ExposeConfiguration(c =>
    {
        c.SetProperty(@"nhibernate-logger", @"Microfilm.Core.NLogFactory, Microfilm.Core");
    })

Implement ILoggerFactory to return a class that implements IInternalLogger. It's pretty straightforward what to include in the IInternalLogger methods; you're just bridging the calls for the NHibernate logger to NLog calls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top