title: Log4Net exception while writing exception to MySQL database
body: <p>When logging an exception, it is correctly shown in the command line. However, it does not write to the database. The other parameters are logged correctly.</p>
  
  <p>In my <code>app.config</code>, the exception is configured as follows:</p>
  
  <pre><code>&lt;commandText value="INSERT INTO logs (time, log_level, logger, message, exception, thread) VALUES (?time, ?log_level, ?logger, ?message, ?exception, ?thread)" /&gt;
  </code></pre>
  
  <p>Parameter:</p>
  
  <pre><code>&lt;parameter&gt;
      &lt;parameterName value="exception" /&gt;
      &lt;dbType value="String" /&gt;
      &lt;size value="2000" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%exception" /&gt;
      &lt;/layout&gt;
  &lt;/parameter&gt;
  </code></pre>
  
  <p>I am testing with:</p>
  
  <pre><code>try
  {
      throw new DivideByZeroException();
  }
  catch (Exception e)
  {
      log.Error("", e);
  }  
  </code></pre>
  
  <p>I enabled Log4Net debugging and got the following output:</p>
  
  <pre><code>log4net: Hierarchy Threshold []
  A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
  log4net:ERROR [CustomAdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database
  12:25:37,902 [Game.Program] {exceptions} () ERROR:  System.DivideByZeroException: Attempted to divide by zero.
     at Game.Program.Init() in --:line 98
  
  log4net:ERROR [CustomAdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database
  System.FormatException: Input string was not in a correct format.
     at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
     at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
     at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
     at System.Convert.ToInt32(Object value)
     at MySql.Data.Types.MySqlInt32.MySql.Data.Types.IMySqlValue.WriteValue(MySqlPacket packet, Boolean binary, Object val, Int32 length)
     at MySql.Data.MySqlClient.MySqlParameter.Serialize(MySqlPacket packet, Boolean binary, MySqlConnectionStringBuilder settings)
     at MySql.Data.MySqlClient.Statement.SerialiSystem.FormatException: Input string was not in a correct format.
     at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
     at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
     at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
     at System.Convert.ToInt32(Object value)
     at MySql.Data.Types.MySqlInt32.MySql.Data.Types.IMySqlValue.WriteValue(MySqlPacket packet, Boolean binary, Object val, Int32 length)
     at MySql.Data.MySqlClient.MySqlParameter.Serialize(MySqlPacket packet, Boolean binary, MySqlConnectionStringBuilder settings)
     at MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName, Int32 parameterIndex)
     at MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
     at MySql.Data.MySqlClient.Statement.BindParameters()
     at MySql.Data.MySqlClient.Statement.Execute()
     at MySql.Data.MySqlClient.PreparableStatement.Execute()
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
     at log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
     at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
  zeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName, Int32 parameterIndex)
     at MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
     at MySql.Data.MySqlClient.Statement.BindParameters()
     at MySql.Data.MySqlClient.Statement.Execute()
     at MySql.Data.MySqlClient.PreparableStatement.Execute()
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
     at log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
     at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
  </code></pre>