Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 401523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:02:30+00:00 2026-05-12T17:02:30+00:00

This is my first serious project using NHibernate and I have setup log4net to

  • 0

This is my first serious project using NHibernate and I have setup log4net to output the sql generated by NHibernate but after running my web app I cannot find any log files.

This web app is currently being run on my local machine with http://localhost/dispatch. The dispatch directory is a virtual directory in IIS pointing to a project folder in My Documents/Visual Studio 2008/Projects.

Here is the relavent portion of Web.config

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="connection.provider">
            NHibernate.Connection.DriverConnectionProvider
        </property>
        <property name="dialect">
            NHibernate.Dialect.MsSql2008Dialect
        </property>
        <property name="connection.driver_class">
            NHibernate.Driver.SqlClientDriver
        </property>
        <property name="connection.connection_string">
            my connection string
        </property>
        <property name="proxyfactory.factory_class">
            NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
        </property>
        <property name="show_sql">true</property>
    </session-factory>
</hibernate-configuration>

<log4net>
    <appender name="NHibernateFileLog" type="log4net.Appender.FileAppender">
        <file value="logs/nhibernate.txt" />
        <appendToFile value="false" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%d{HH:mm:ss.fff} [%t] %-5p %c - %m%n"  />
        </layout>
    </appender>
    <logger name="NHibernate.SQL" additivity="false">
        <level value="INFO"/>
        <appender-ref ref="NHibernateFileLog"/>
    </logger>
</log4net>

Also my Global.asax file looks like this:

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

namespace DispatchBoard {
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication {
        public static void RegisterRoutes(RouteCollection routes) {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

        }

        protected void Application_Start() {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}

Please let me know what I am doing wrong. I need to see this output to debug an inefficient SQL query. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:02:31+00:00Added an answer on May 12, 2026 at 5:02 pm

    You might have to configure the NHibernate.SQL section in web.config to have it set the level to DEBUG (but not INFO). You also are missing the NHibernate.Loader.Loader section

    <logger name="NHibernate.SQL" additivity="false">
          <level value="DEBUG" />
          <appender-ref ref="ConsoleAppender" />
        </logger>
        <!-- 
          NHibernate.Loader.Loader logs diagnostic stuff and SELECTs. 
          You can use either logger, or both, depending on you needs.
        -->
        <logger name="NHibernate.Loader.Loader" additivity="false">
          <level value="INFO" />
          <appender-ref ref="ConsoleAppender" />
        </logger>
    

    Here is a post that’s very helpful to enabling SQL logging for NHibernate

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I'm having some serious issues here. I'm new to this site, and new
I have some serious performance issues when querying a sqlite database with approx. 25k
Long story short, I took over a project and a table in the database
I'm having a serious problem with a prestashop shipping module for FedEx. I know
This morning, there were big problems at work because an SNMP trap didn't go
First of all, as you can see, I work in Java and specifically in
A month ago I started working with phonegap, html5, css3 and jQtouch. I am
I'm in a bit of trouble here. I upgraded one of our Winforms products
I've been writing a program that serves in two primary parts- managed UI and
So, I've got a contact form in my MVC 2 application. I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.