日期:2014-05-18  浏览次数:20519 次

vs 2005 用log4net 的问题 哎,,,搞了好久了.郁闷
在winform下很号搞,搞出来了。但webform不行     在web.config   里加了
<configSections>
        <!-- <section   name= "log4net "   type= "System.Configuration.IgnoreSectionHandler "   /> -->

        <section   name= "log4net "   type= "log4net.Config.Log4NetConfigurationSectionHandler,   log4net "   />

    </configSections>
    <appSettings>
        <!--   To   enable   internal   log4net   logging   specify   the   following   appSettings   key   -->
        <!--   <add   key= "log4net.Internal.Debug "   value= "true "/>   -->
    </appSettings>
    <log4net>
        <appender   name= "LogFileAppender "   type= "log4net.Appender.FileAppender ">
            <file   value= "d:\log-file.txt "   />
            <appendToFile   value= "true "   />
            <layout   type= "log4net.Layout.PatternLayout ">
                <header   value= "[Header]&#13;&#10; "   />
                <footer   value= "[Footer]&#13;&#10; "   />
                <conversionPattern   value= "%date   [%thread]   %-5level   %logger   [%ndc]   &lt;%property{auth}&gt;   -   %message%newline "   />
            </layout>
        </appender>
        <root>
            <level   value= "WARN "   />
            <appender-ref   ref= "LogFileAppender "   />
        </root>
    </log4net>
同时又建了个log4net.config里的内容跟上面的一样
在gloab.asax里加了
        [assembly:   log4net.Config.XmlConfigurator(ConfigFile   =   "log4net.config ",   Watch   =   true)]

        void   Application_Start(object   sender,   EventArgs   e)  
        {
                //   在应用程序启动时运行的代码

                log4net.Config.XmlConfigurator.Configure(new   System.IO.FileInfo( "log4net.config "));

        }
在测试的页面里是
using   log4net.Config;

[assembly:   log4net.Config.XmlConfigurator(ConfigFile   =   "log4net.config ",   Watch   =   true)]      
//[assembly:   log4net.Config.XmlConfigurator(Watch   =   true)]
public   partial   class   test   :   System.Web.UI.Page
{

        private   static   readonly   ILog   log   =   LogManager.G