News, examples, tips, ideas and plans.
Thoughts around ORM, .NET and SQL databases.

Monday, March 17, 2014

DataObjects.Net 5.0 meets NLog & log4net

In the previous post we explained DataObjects.Net built-in logging capabilities. Now it is time to show how popular logging libraries like log4net and NLog can be integrated with it.

We would need the list of names of built-in logs:

  • Xtensive.Orm - logs Session & Transaction-related events and exceptions.
  • Xtensive.Orm.Building - logs events during the Domain building process.
  • Xtensive.Orm.Sql - logs SQL statements sent to database server.
  • Xtensive.Orm.Upgrade - logs events during database schema upgrade.

  • log4net

    1. Add DataObjects.Net logging provider for log4net. It will automatically add log4net.
    2. Set up log provider in Xtensive.Orm configuration section

           <domain ... >
         <logging provider="Xtensive.Orm.Logging.log4net.LogProvider, Xtensive.Orm.Logging.log4net">
    3. Configure log4net. Use the above-mentioned loggers' names, e.g.:

       <?xml version="1.0" encoding="utf-8" ?>
           <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
           <appender name="ConsoleAppernder" type="log4net.Appender.ConsoleAppender">
             <layout type="log4net.Layout.PatternLayout">
               <conversionPattern value="%date [%thread] %-5level %logger %message%newline" />
           <logger name="Xtensive.Orm">
             <level value="ALL" />
             <appender-ref ref="ConsoleAppernder" />


    1. Add DataObjects.Net logging provider for NLog. It will automatically add NLog.
    2. Set up log provider in Xtensive.Orm configuration section

           <domain ... >
         <logging provider="Xtensive.Orm.Logging.NLog.LogProvider, Xtensive.Orm.Logging.NLog">
    3. Configure NLog. Use the above-mentioned loggers' names, e.g.:

          <?xml version="1.0" encoding="utf-8" ?>
          <nlog xmlns=""
              <target name="console" xsi:type="Console" />
              <logger name="Xtensive.Orm" minlevel="Debug" writeTo="console" />

    Pretty simple, huh? You can even write your own log provider with ease. Just take a look at the implementation of these two in DataObjects.Net Extensions repository, default branch.


    1. Best windows hosting india have their own benefits and disadvantages. Understanding the advantages and minuses about them could assist you to choose between them. Windows is actually known for predictable achievement, and Microsoft provides continual auto updates to web hosting providers and computer customers.

    2. When you are choosing a best web hosting company in jaipur, it is important so as to you rely on more than just one or two pieces of suggestion on a recommendation. Many recommendations are from customer who hasn’t even experienced the web hosting company that they are recommending.

    3. There are many cheap dedicated server hosting companies in india, But a startup is very reliable among them.