- Enable log4net logging for your web application. This can be done by putting following line into Global.asax code-behind:
protected void Application_Start() { log4net.Config.XmlConfigurator.Configure(); // Other statements suppressed. }
- Update the web.config file of your web application to enable NHibernate SQL logging to a text file:
<?xml version="1.0"?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> ... </configSections> <log4net> <appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net" > <param name="File" value="Logs/log.txt" /> <param name="AppendToFile" value="false" /> <param name="RollingStyle" value="Date" /> <param name="DatePattern" value="yyyy.MM.dd" /> <param name="StaticLogFileName" value="true" /> <layout type="log4net.Layout.PatternLayout,log4net"> <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" /> </layout> </appender> <logger name="NHibernate.SQL" additivity="false"> <level value="DEBUG"/> <appender-ref ref="rollingFile"/> </logger> </log4net> </configuration>
Sunday, January 1, 2012
Configure NHibernate SQL logging for ASP.NET web application
Let me share quick instructions for enabling NHibernate SQL logging for ASP.NET web application (default log4net logging). Two steps need to be taken:
Labels:
NHibernate
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment