Return-Path: X-Original-To: apmail-logging-log4net-dev-archive@www.apache.org Delivered-To: apmail-logging-log4net-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 023D518ABF for ; Mon, 23 Nov 2015 20:37:12 +0000 (UTC) Received: (qmail 56774 invoked by uid 500); 23 Nov 2015 20:37:11 -0000 Delivered-To: apmail-logging-log4net-dev-archive@logging.apache.org Received: (qmail 56675 invoked by uid 500); 23 Nov 2015 20:37:11 -0000 Mailing-List: contact log4net-dev-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET Dev" List-Id: Delivered-To: mailing list log4net-dev@logging.apache.org Received: (qmail 56497 invoked by uid 99); 23 Nov 2015 20:37:11 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2015 20:37:11 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 475D92C1F5B for ; Mon, 23 Nov 2015 20:37:11 +0000 (UTC) Date: Mon, 23 Nov 2015 20:37:11 +0000 (UTC) From: "Dominik Psenner (JIRA)" To: log4net-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LOG4NET-495) Error when BufferSize is >1, parameter already defined MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4NET-495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15022945#comment-15022945 ] Dominik Psenner commented on LOG4NET-495: ----------------------------------------- Thanks for testing the appender. Your report is sound and I'll fix it as you suggested. I'll also try to write down a test so that we can be sure this usecase is covered by the unittests. > 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 > > 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)