NHibernate NLog support in Nuget

I have created a new package that add support for writing NHibernate logs with NLog.
The package is not a dll but only one class.

In order to use this package, simply install with nuget:

2011-05-04_0838

This is an example app.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
  </configSections>
  <appSettings>
    <add key="nhibernate-logger" value="YourNamespace.NLogFactory, YourAssemblyName"/>
  </appSettings>

  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
      <target name="ds" xsi:type="Console"/>
    </targets>
    <rules>
      <logger name="NHibernate.SQL" minlevel="Debug" writeTo="ds" />
    </rules>
  </nlog>
</configuration>

Remember to change “YourNamespace” and “YourAssemblyName”. That is all.
You don’t need to run Configure or some initialization code as in log4net.

There is an alternative approach here but it is a little bit more complicated.


blog comments powered by Disqus
  • Categories

  • Archives