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:


This is an example app.config file:

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

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

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