Do you have a log4net config handler defined in web.config so .NET knows how to 
handle the <log4net> node:

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

Your AdoNetAppender is set to buffer 100 log messages before inserting them 
into the database. Try setting that value to 1 for the time being.




________________________________
From: Wade DeWerff <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, November 26, 2008 10:03:33 AM
Subject: cant get log4net to log


What's missing here? Using profiler, the database never 
receives the call. I tried adding a File appender and that didn't work either. 

web.config: 
    <log4net> 
        <appender 
name="ADONetAppender" type="log4net.Appender.ADONetAppender"> 
  
          <bufferSize value="100" /> 
  
          <connectionType 
value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
      
      <connectionString value="data 
source=(local)\SQLEXPRESS;initial catalog=MyTestDB;integrated 
security=false;persist security info=True;User ID=user;Password=pass" /> 
            <commandText value="INSERT INTO 
Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, 
@thread, @log_level, @logger, @message, @exception)" /> 
........ etc 
        <root> 
        
    <level value="ERROR" /> 
        
    <appender-ref ref="ADONetAppender" /> 
    
    </root> 
        <logger 
name="LogUtility"> 
            <level 
value="ALL" /> 
        </logger> 
</log4net> 

 
 

global.asax application_start 
log4net.Config.XmlConfigurator.Configure(); 

 
 

log wrapper: 
    public class LogUtility 
: ILogUtility 
    { 
        private ILog 
log { get; set; } 

        public LogUtility() 
        { 
            
log = LogManager.GetLogger("LogUtility"); // 
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 
        } 

        #region 
ILogUtility Members 

        public void 
LogException(string message) 
        { 
    
        log.Error(message); 
        
} 

        public void LogException(string message, 
Exception exception) 
        { 
      
      log.Error(message, exception); 
      
  } 

 
 
 
.aspx log call: 
 LogUtility.LogException("some error", new Exception()); 

Reply via email to