AssemblyInfo.cs 
 

   添加 
 
 
 

   [assembly: log4net.Config.XmlConfigurator(ConfigFile="log4net.config")] 
 
 
 
 
  
 
 
web根目录下log4net.config
 
 

    <?xml version="1.0" encoding="utf-8" ?> 
  
 
  

    <log4net> 
  
 
  
 
   <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> 
  
 
  
 
   <file value="log\fluorine.log" /> 
  
 
  
 
   <appendToFile value="true" /> 
  
 
  
 
   <rollingStyle value="Date" /> 
  
 
  
 
   <datePattern value="yyyyMMdd" /> 
  
 
  
 
   <layout type="log4net.Layout.PatternLayout"> 
  
 
  
 
   <!-- <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> --> 
  
 
  
 
   <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> 
  
 
  
 
   </layout> 
  
 
  
 
   </appender> 
  
 
  
 
   <root> 
  
 
  
 
   <level value="ERROR" /> 
  
 
  
 
   <appender-ref ref="RollingLogFileAppender" /> 
  
 
  
 
   </root> 
  
 
  
 
   <logger name="Test"> 
  
 
  
 
   <level value="DEBUG" /> 
  
 
  
 
   </logger> 
  
 
  

    </log4net> 
  
 
 
 
  
 
 
记录日志
 
 

   public static log4net.ILog logger = log4net.LogManager.GetLogger("Test"); 
 
 
 
 
  
 
 

   logger.Info("测试日志");