首页 新闻 会员 周边 捐助

ActiveRecord 无法使用log4net记录日志

0
悬赏园豆:50 [已关闭问题]
<P>这个问题困扰我很久了,在网上搜了一大堆互相抄袭的文章之后未果,特来请求帮助。</P> <P>我按照网上介绍的方法写的web.config</P> <P>-------------------------------------<BR>&lt;?xml version="1.0"?&gt;<BR>&lt;configuration&gt;<BR>&nbsp; &lt;configSections&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;section name="monorail" type="Castle.MonoRail.Framework.Configuration.MonoRailSectionHandler, Castle.MonoRail.Framework"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/&gt;<BR>&nbsp; &lt;/configSections&gt;<BR>&nbsp; &lt;appSettings/&gt;<BR>&nbsp; &lt;connectionStrings/&gt;<BR>&nbsp; &lt;activerecord isWeb="true"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;config&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add key="hibernate.connection.connection_string" value="********"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/config&gt;<BR>&nbsp; &lt;/activerecord&gt;<BR>&nbsp; &lt;monorail&gt;<BR>&nbsp; ....<BR>&nbsp; &lt;/monorail&gt;<BR>&nbsp; &lt;log4net&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;!-- Define some output appenders --&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;appener name="trace" type="log4net.Appender.TraceAppender, log4net"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout,log4net"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &amp;lt;%P{user}&amp;gt; - %m%n"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/appener&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;appener name="console" type="log4net.Appender.ConsoleAppender, log4net"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout,log4net"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &amp;lt;%P{user}&amp;gt; - %m%n"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/appener&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;appener name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;param name="File"
问题补充: 呃,内容太长,被截断了。。 配置我基本上完全照搬 terrylee的文章http://terrylee.cnblogs.com/archive/2006/04/14/374829.html来的(网上搜索出来的几乎都和他一摸一样) 我认真对比了terrylee的方法和我的代码,确认没有什么不同的地方,可就是找不到log.txt文件,请求同学们帮助。
兜小神的主页 兜小神 | 初学一级 | 园豆:120
提问于:2007-12-01 14:44
< >
分享
其他回答(2)
0
你留言给terrylee吧,说明你的问题,也许能得到点帮助
AndyFish | 园豆:1575 (小虾三级) | 2007-12-05 12:22
0

<log4net debug="false">

<root>
<level value="INFO" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="D:\\LOG\\DBLog.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n" />
</layout>
</appender>
</log4net>

 

我找了其他的试成功的 你试试看

iv3 | 园豆:202 (菜鸟二级) | 2014-07-20 16:07
0

我也遇到这个问题了,找不到log.txt,楼主是否解决了,分享下吧

邢帅杰 | 园豆:177 (初学一级) | 2016-03-29 16:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册