Log4net
  1. Log4net
  2. LOG4NET-211

Log4net with MS Access 2007 for asp.net 3.5 website

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2 Maintenance Release
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      Windows XP, VS 2008, MS Access 2007

      Description

      Hello,

      I am using log4net for asp.net 3.5 website for logging exceptions into the MS Access 2007 (*accdb ). I had done following settings:

      1. Created log4net config file

      <?xml version="1.0" encoding="utf-8" ?>
      <log4net debug="false">
      <appender name="AdoNetAppender_Access" type="log4net.Appender.AdoNetAppender">
      <connectionString value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|EAlog.accdb;Persist Security Info=False;" />
      <commandText value="INSERT INTO Logs ([LogDate],[Thread],[Level],[Logger],[Message]) VALUES (@LogDate, @Thread, @Level, @Logger, @Message)" />
      <parameter>
      <parameterName value="@LogDate" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@Thread" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%thread" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@Level" />
      <dbType value="String" />
      <size value="50" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%level" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@Logger" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%logger" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@Message" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%message" />
      </layout>
      </parameter>
      </appender>
      <!--<root>
      <level value="DEBUG" />
      <appender-ref ref="AdoNetAppender_Access"/>
      </root>-->
      <logger name="File">
      <level value="All" />
      <appender-ref ref="AdoNetAppender_Access" />
      </logger>
      </log4net>
      <!--<log4net>
      <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingLogFileAppender"/>
      </root>
      <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="logsapp.log" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="100KB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d [%t]%-5p %c [%x] - %m%n" />
      </layout>
      </appender>
      <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="logsapp.log" />
      <appendToFile value="false" />
      <datePattern value="-dddd" />
      <rollingStyle value="Date" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d [%t]%-5p %c [%x] - %m%n" />
      </layout>
      </appender>
      </log4net>-->

      <!-Log4net->
      <!--<log4net>
      <appender name="AdoNetAppender_Access" type="log4net.Appender.AdoNetAppender">
      <connectionString value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|Logs.accdb;Persist Security Info=False;" />
      <commandText value="INSERT INTO Logs ([LogDate],[Thread],[Level],[Logger],[Message]) VALUES (?, ?, ?, ?, ?)" />
      <parameter>
      <parameterName value="LogDate" />
      <dbType value="DateTime" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%LogDate" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="Thread" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%Thread" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="Level" />
      <dbType value="String" />
      <size value="50" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%Level" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="Logger" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%Logger" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="Message" />
      <dbType value="String" />
      <size value="1024" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%Message" />
      </layout>
      </parameter>
      </appender>

      <root>
      <level value="DEBUG" />
      <appender-ref ref="AdoNetAppender_Access"/>
      </root>

      </log4net>-->
      <!-End of log4net->

      2. In app.config file:

      void Application_Start(object sender, EventArgs e)
      {
      string logFile = HttpContext.Current.Request.PhysicalApplicationPath + "log4net.config";
      if (System.IO.File.Exists(logFile))

      { log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(logFile)); }

      }

      3. In aspx page

      private static readonly ILog log = LogManager.GetLogger("File");

      log.Error("This is an error message");
      log.Debug("This is a debug message");

      Now what happens is when I browse the aspx page, it is logging exceptions after 10-15 min in the logs MS Access table. During my investigation, when I opened app_data folder I am able to see Logs.laccdb database getting created and after 10-15min this file is getting deleted and rows are added into the table. I think log4net is locking the database for such time and performing the insert statements.

      Could you please guide me if I am doing anything wrong.

      Thanks,
      Sundeep.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            sundeep
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 840h
              840h
              Remaining:
              Remaining Estimate - 840h
              840h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development