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

  • Home
  • SEARCH
  • 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 6073241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:14:58+00:00 2026-05-23T10:14:58+00:00

This is how I create Session Factory using Fluent Nhibernate public static ISessionFactory CreateSessionFactory()

  • 0

This is how I create Session Factory using Fluent Nhibernate

    public static ISessionFactory CreateSessionFactory()
        {
            FluentNHibernate.Cfg.FluentConfiguration fconfig;


            fconfig = FluentNHibernate.Cfg.Fluently.Configure()
                        .Cache(c=>c.UseQueryCache())
                        .Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008 
                                        .ConnectionString(c => c.FromConnectionStringWithKey("Database"))
                        .ProxyFactoryFactory<NHibernate.ByteCode.LinFu.ProxyFactoryFactory>()
                        .Mappings(
                                  m =>  m.FluentMappings
                                        .AddFromAssemblyOf<NHibernateRepositoryRegistry>()
                                        .Conventions.Add<Conventions.PrimaryKeyConvention>()
                                        .Conventions.Add<Conventions.IdForeignKeyConvention>()
                                        .Conventions.Add<Conventions.ReferenceForeignKeyConstraintNameConvention>()
                            )
                   //  i have tried this but it did not work
                   //.ExposeConfiguration(config=>{config.SetProperty("show_sql", "false");});
           return fconfig.BuildSessionFactory();
        }

This is my log4net config inside Web.config

    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
        <file value="nhibernate.log" />
        <appendToFile value="true" />
        <maximumFileSize value="100KB" />
        <maxSizeRollBackups value="2" />

        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%level %thread %logger - %message%newline" />
        </layout>
    </appender>
    <appender name="RollingFile2" type="log4net.Appender.RollingFileAppender">
        <file value="nhibernatesql.log" />
        <appendToFile value="true" />
        <maximumFileSize value="100KB" />
        <maxSizeRollBackups value="2" />

        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%level %thread %logger - %message%newline" />
        </layout>
    </appender>
    <logger name="NHibernate">
        <level value="INFO" />
        <appender-ref ref="RollingFile" />
    </logger>


    <logger name="NHibernate.SQL">
        <level value="ALL" />
        <appender-ref ref="RollingFile2" />
    </logger>
    <root>
        <level value="DEBUG" />
        <appender-ref ref="RollingFile" />
    </root>

</log4net>  

I had ShowSql() setup perviously

and I was trying to set it via web.config appsettings so i can turn on or off based on configuration

so I removed ShowSql() and tried following ( right now i am just passing “false” value )

.ExposeConfiguration(config=>{config.SetProperty("show_sql", "false");});

also tried

.ExposeConfiguration(config=>{config.SetProperty("hibernate.show_sql", "false");});

but I am still getting sql generated in nhibernatesql.log file

I am using NHibernate v3.1.0.4000 and FluentNHibernate v1.2.0.712 and ASP.NET MVC3

does anyone know why sql is still generating?

does show_sql or ShowSql() is only meant for Console.output purpose and sql is sent to log4net regardless ?

my main concern is slow performance if ShowSQL is set to true

not sure whether I am setting ShowSql somewhere else

  • 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-23T10:14:59+00:00Added an answer on May 23, 2026 at 10:14 am

    ok I think I got the answer

    based on http://www.davesquared.net/2008/01/viewing-sql-generated-by-nhibernate.html

    show_sql is used of Console.out purpose only and sql is sent to log4net regardless.. and that is why I am seeing sql in the logs

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

Sidebar

Related Questions

I have this administration site that is using (Fluent) NHibernate for data access. As
Hi I start learn Fluent NHibernate. I am using this tutorial http://www.d80.co.uk/post/2011/02/20/Linq-to-NHibernate-Tutorial.aspx . Here
This table is used to store sessions (events): CREATE TABLE session ( id int(11)
We are getting this error: System.ServiceModel.ServerTooBusyException: The request to create a reliable session has
Question follows on from Fluent NHibernate + multiple databases (no need to follow this
I have a WPF application running with VS2010 .Net3.5 using Nhibernate with FluentNHibernate +
I have a Java program using a basic Hibernate session factory. I had an
I recently asked a question about using Fluent NHibernate with .NET 4 - I
I've just started using Fluent NHibernate and have run into the following problem trying
I'm enjoying using Fluent NHibernate with AutoMappings but every now and then I get

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.