Another log4net, fluent nhibernate configuration issue
This is driving me crazy... I've spent half a day trying to turn everything aroung but I can't get log4net to spit out anything about NHibernate.
Here's my current Fluent NHibernate config:
var configuration = Fluently.Configure()
    .Database(SQLiteConfiguration.Standard.UsingFile(AppConstants.PATH_FILENAME_DB))
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<...>())
    [...Mappings...]
    .Diagnostics(x => x.Enable());
My app.config:
<configSections>
  <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
  <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
    <param name="File" value="data/log/unprocessed.log"/>
    <param name="AppendToFile" value="true"/>
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/>
    </layout>
  </appender>
  <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/>
    </layout>
  </appender>
  <logger name="NHibernate.SQL" additivity="false">
    <level value="ALL"/>
    <appender-ref ref="LogFileAppender"/>
  </logger>
  <root>
    <level value="INFO"/>
    <appender-ref ref="LogFileAppender"/>
  </root>
</log4net>
I can log stuff right after I initialize the main form:
log4net.Config.XmlConfigurator.Configure();
logger.Info("Here is a debug log!!");
And it works 100%. However I'm not able to get anything out of Nhibernate.
I've tried:
My Fluent Nhibernate mappings are good, my app is working perfectly without log4net.
I still am unable to log any queries from NHibernate... Not sure what is going on but if you have a clue I'll be happy to try it out!!!
Thanks!
Well I ended up finding the issue...
All my DLLs were located in /lib folder instead of the output folder.
Part of my app.config had this:
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <probing privatePath="lib"/>
    <dependentAssembly>
      <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089"/>
      <bindingRedirect oldVersion="2.0.0.0" newVersion="4.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>
Putting log4net.dll in my output folder fixed the issue.
链接地址: http://www.djcxy.com/p/39458.html