You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Dominik Psenner (JIRA)" <ji...@apache.org> on 2015/11/27 21:26:11 UTC

[jira] [Comment Edited] (LOG4NET-495) Error when BufferSize is >1, parameter already defined

    [ https://issues.apache.org/jira/browse/LOG4NET-495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15030219#comment-15030219 ] 

Dominik Psenner edited comment on LOG4NET-495 at 11/27/15 8:26 PM:
-------------------------------------------------------------------

While writing a test I noticed that your solution does not break existing tests and therefore I adjusted the patch. Should be fixed now and I'm resolving the issue. It would be nice if you could run log4net from source and confirm that the latest trunk fixes your issue. We can then close the issue.


was (Author: nachbarslumpi):
While writing a test I noticed that your solution does not break existing tests and therefore I adjusted the patch. Should be fixed now and I'm closing the issue. It would be nice if you could run log4net from source and confirm that the latest trunk fixes your issue.

> Error when BufferSize is >1, parameter already defined
> ------------------------------------------------------
>
>                 Key: LOG4NET-495
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-495
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.15
>         Environment: Windows 7
>            Reporter: Rick Burge
>            Assignee: Dominik Psenner
>             Fix For: 1.2.15
>
>
> Downloaded the subject revision 1714197 in order to get the ADONetAppender_SqlServer appender to work as this revision corrected a problem. The appender began to work. However if the BufferSize was increased to >1 an error was reported that the parameter @log_date was already defined.
> The error appears to be in SendBuffer. Because the IDbCommand dbCmd is being reused inside the foreach (LoggingEvent e in Events), each time the param.Prepare(dbCmd) is called for the same appender it will attempt to add a parameter that has already been added.
> My local solution was to clear the commands parameter list prior to adding the preparing the paramters:
>    foreach (LoggingEvent e in events)
>                     {
>                             dbCmd.Parameters.Clear(); //*****added this line*****
>                         // Set the parameter values
>                         foreach (AdoNetAppenderParameter param in m_parameters)
>                         {
>                             param.Prepare(dbCmd);
>                             param.FormatValue(dbCmd, e);
>                         }
>                         // Execute the query
>                         dbCmd.ExecuteNonQuery();
>                     }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)