castle故障检测

来源: http://wiki.castleproject.org/index.php/ActiveRecord:Troubleshooting
故障检测
有时候你的映射可能存在一些错误,或者你想看你的sql语句到底是什么一回事这个时候我们就需要把 NHibernate 的日记记录打开

允许日记记录
nhibernate用的是log4net. 以下的配置中他是将信息写到 log.txt中的(程序运行的时候被锁定了你可以拷贝一份来查看)
castle故障检测 <? xml version="1.0" encoding="utf-8"  ?>  
castle故障检测
castle故障检测
< configuration >
castle故障检测
castle故障检测    
< configSections >
castle故障检测    
< section  name ="nhibernate"  type ="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"   />  
castle故障检测        
< section  name ="activerecord"
castle故障检测                 type
="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord"   />
castle故障检测        
< section  name ="log4net"
castle故障检测                 type
="log4net.Config.Log4NetConfigurationSectionHandler, log4net"   />
castle故障检测    
</ configSections >
castle故障检测
castle故障检测    
< activerecord >
castle故障检测      
castle故障检测    castle故障检测
castle故障检测      
castle故障检测    
</ activerecord >
castle故障检测    
castle故障检测    
< log4net >
castle故障检测
castle故障检测        
<!--  Define some output appenders  -->
castle故障检测        
< appender  name ="trace"  type ="log4net.Appender.TraceAppender, log4net" >
castle故障检测            
< layout  type ="log4net.Layout.PatternLayout,log4net" >
castle故障检测                
< param  name ="ConversionPattern"  value ="%d [%t] %-5p %c [%x] &lt;%P{user}&gt; - %m%n"   />
castle故障检测            
</ layout >
castle故障检测        
</ appender >
castle故障检测
castle故障检测        
< appender  name ="console"  type ="log4net.Appender.ConsoleAppender, log4net" >
castle故障检测            
< layout  type ="log4net.Layout.PatternLayout,log4net" >
castle故障检测                
< param  name ="ConversionPattern"  value ="%d [%t] %-5p %c [%x] &lt;%P{user}&gt; - %m%n"   />
castle故障检测            
</ layout >
castle故障检测        
</ appender >
castle故障检测
castle故障检测        
< appender  name ="rollingFile"  type ="log4net.Appender.RollingFileAppender,log4net"   >
castle故障检测            
< param  name ="File"  value ="log.txt"   />
castle故障检测            
< param  name ="AppendToFile"  value ="true"   />
castle故障检测            
< param  name ="RollingStyle"  value ="Date"   />
castle故障检测            
< param  name ="DatePattern"  value ="yyyy.MM.dd"   />
castle故障检测            
< param  name ="StaticLogFileName"  value ="true"   />
castle故障检测
castle故障检测            
< layout  type ="log4net.Layout.PatternLayout,log4net" >
castle故障检测                
< param  name ="ConversionPattern"  value ="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n"   />
castle故障检测            
</ layout >
castle故障检测            
castle故障检测        
</ appender >
castle故障检测
castle故障检测        
< root >
castle故障检测            
<!--  priority value can be set to ALL|INFO|WARN|ERROR  -->
castle故障检测            
< priority  value ="ALL"   />
castle故障检测            
< appender-ref  ref ="rollingFile"   />
castle故障检测        
</ root >
castle故障检测
castle故障检测    
</ log4net >
castle故障检测
castle故障检测    
< nhibernate >  
castle故障检测        
<!--  with this set to true, SQL statements will output to the console window if it's a console app  -->
castle故障检测        
< add  key ="hibernate.show_sql"  value ="true"   />
castle故障检测    
</ nhibernate >
castle故障检测
</ configuration >
castle故障检测
castle故障检测

在完成这个之后你必须调用这个方法
log4net.Config.XmlConfigurator.Configure();
一般写在 global.asax中
注意这个方法必须写在ActiveRecordStarter.Initialize(...)之前

你可以在log.txt中搜索你的hql语句.这样就可以在下面的几行里看到sql语句了

你可能感兴趣的:(cast)