Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-489

AdoNetAppender fails after upgrade to 2.0.4

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.14
    • Fix Version/s: 1.2.15
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      Windows

      Description

      with 1.2.13 everything is working fine.
      Update to 1.2.14 (2.0.4 on Nuget), logging fails.
      I would have attached screenshots, but can't work out how.

      For example

      <connectionType
      value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionStringName value="LabelPrint" />
      <commandText
      value="INSERT INTO dbo.Logging ([LogDate],[Level],[Operation],[OperationInfo],[User],[Label],[Application],[CorrelationId],[Method],[Line],[Logger],[Message],[Exception])
      VALUES (@log_date, @log_level, @operation, @operationInfo, @user, @label, @application, @correlationId, @pgm_method, @pgm_line, @logger, @message, @exception)" />
      <parameter>
      <parameterName value="@log_date" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.RawUtcTimeStampLayout" />
      </parameter>
      ... etc

      This now causes the error

      'Exception while writing to database System.IndexOutOfRangeException: An SqlParameter with ParamerName '@log_date' is not contained by this SqlParameterCollection ....

        Issue Links

          Activity

          Hide
          nachbarslumpi Dominik Psenner added a comment -

          It will have to do with this change, but I do not yet understand why this is the case. Apologies for the inconvenience, I'm on it.

          Revision: 1711736
          Author: dpsenner
          Date: 01 November 2015 12:50:44
          Message:
          LOG4NET-461: refactored the AdoNetAppender

          The AdoNetAppender suffered several issues. One was that a database command was
          created and stored for the appenders lifetime. This caused trouble with some
          database servers because those cleaned up cached prepared statements from time to
          time and thus caused the appender to fail without the capability to recover. I
          solved this problem by creating a database command whenever the buffer is sent,
          well knowing that this costs a little more performance but is much more stable.

          At this point I further took the chance to cleanup the source by replacing all
          references to private member attributes with their public property mapping.
          Further I added and fixed some of the documentation.

          This overall cleanup is not yet complete, meaning that there is still a connection
          that is being kept alive while it would be wiser to rely on proper connection
          pooling and just open/close the database connection when sending the buffer. I
          will raise this topic on the dev list.


          Modified : /logging/log4net/trunk/src/Appender/AdoNetAppender.cs

          Show
          nachbarslumpi Dominik Psenner added a comment - It will have to do with this change, but I do not yet understand why this is the case. Apologies for the inconvenience, I'm on it. Revision: 1711736 Author: dpsenner Date: 01 November 2015 12:50:44 Message: LOG4NET-461 : refactored the AdoNetAppender The AdoNetAppender suffered several issues. One was that a database command was created and stored for the appenders lifetime. This caused trouble with some database servers because those cleaned up cached prepared statements from time to time and thus caused the appender to fail without the capability to recover. I solved this problem by creating a database command whenever the buffer is sent, well knowing that this costs a little more performance but is much more stable. At this point I further took the chance to cleanup the source by replacing all references to private member attributes with their public property mapping. Further I added and fixed some of the documentation. This overall cleanup is not yet complete, meaning that there is still a connection that is being kept alive while it would be wiser to rely on proper connection pooling and just open/close the database connection when sending the buffer. I will raise this topic on the dev list. Modified : /logging/log4net/trunk/src/Appender/AdoNetAppender.cs
          Hide
          nachbarslumpi Dominik Psenner added a comment -

          Fix committed with svn revision 1714197. Would you please try the latest log4net from src to see if the issue is gone? I'll start a release vote as soon as you can confirm the fix.

          Show
          nachbarslumpi Dominik Psenner added a comment - Fix committed with svn revision 1714197. Would you please try the latest log4net from src to see if the issue is gone? I'll start a release vote as soon as you can confirm the fix.
          Hide
          ImpPhil2 Philip Lee added a comment -

          Not sure how to get the latest source - see attached.

          Show
          ImpPhil2 Philip Lee added a comment - Not sure how to get the latest source - see attached.
          Hide
          nachbarslumpi Dominik Psenner added a comment -

          You could checkout from svn from the url:
          http://svn.apache.org/repos/asf/logging/log4net/trunk

          Show
          nachbarslumpi Dominik Psenner added a comment - You could checkout from svn from the url: http://svn.apache.org/repos/asf/logging/log4net/trunk
          Hide
          ImpPhil2 Philip Lee added a comment -

          Any chance you can build it and give me a download link?

          Show
          ImpPhil2 Philip Lee added a comment - Any chance you can build it and give me a download link?
          Hide
          nachbarslumpi Dominik Psenner added a comment -

          Sure, I can build it for .NET 4.5 and put it on dropbox. But not before tomorrow morning (8AM UTC).

          Show
          nachbarslumpi Dominik Psenner added a comment - Sure, I can build it for .NET 4.5 and put it on dropbox. But not before tomorrow morning (8AM UTC).
          Hide
          ImpPhil2 Philip Lee added a comment -

          Thanks.

          Show
          ImpPhil2 Philip Lee added a comment - Thanks.
          Hide
          nachbarslumpi Dominik Psenner added a comment -

          I had the chance to build this earlier than expected. You can download it from here:

          https://www.dropbox.com/s/b9vdg9gr45m4nwh/log4net.zip?dl=0

          Please note that this link will expire in about 72 hours.

          Show
          nachbarslumpi Dominik Psenner added a comment - I had the chance to build this earlier than expected. You can download it from here: https://www.dropbox.com/s/b9vdg9gr45m4nwh/log4net.zip?dl=0 Please note that this link will expire in about 72 hours.
          Hide
          ImpPhil2 Philip Lee added a comment - - edited

          Yes I can confirm that fixes the issue.

          Show
          ImpPhil2 Philip Lee added a comment - - edited Yes I can confirm that fixes the issue.
          Hide
          nachbarslumpi Dominik Psenner added a comment -

          That's great. We'll ship a bugfix release soon.

          Show
          nachbarslumpi Dominik Psenner added a comment - That's great. We'll ship a bugfix release soon.
          Hide
          kotolows Marek K added a comment - - edited

          Hi Guys,
          I desperately need the build for .net 4.5 with the fix for this issue. Could you send me a working link to download? Can you make it last longer than 72 hours?

          Thanks in advance.

          Edit: Forgot to mention that the file should be signed with the new key.

          Show
          kotolows Marek K added a comment - - edited Hi Guys, I desperately need the build for .net 4.5 with the fix for this issue. Could you send me a working link to download? Can you make it last longer than 72 hours? Thanks in advance. Edit: Forgot to mention that the file should be signed with the new key.
          Hide
          nachbarslumpi Dominik Psenner added a comment - - edited

          Hi Marek,

          I understand your point, but we will not provide unofficial binaries to be used in production environments. Please download 1.2.13 from the archives or build the latest trunk from source.

          Cheers

          Show
          nachbarslumpi Dominik Psenner added a comment - - edited Hi Marek, I understand your point, but we will not provide unofficial binaries to be used in production environments. Please download 1.2.13 from the archives or build the latest trunk from source. Cheers
          Hide
          hikaruu hikaruu added a comment -

          I have the same bug. Please reupload this build!

          Show
          hikaruu hikaruu added a comment - I have the same bug. Please reupload this build!
          Hide
          bodewig Stefan Bodewig added a comment -

          I hope you've seen we've released 1.2.15 by now.

          Show
          bodewig Stefan Bodewig added a comment - I hope you've seen we've released 1.2.15 by now.

            People

            • Assignee:
              nachbarslumpi Dominik Psenner
              Reporter:
              ImpPhil2 Philip Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development