Hi, Has anyone ever experienced frequent "closed connection" errors in log4net while using the AdoNetAppender with MySQL Connector/NET in an ASP.NET application (stack traces below)?
I know this isn't strictly a log4net question, but I'm wondering if anything about log4net might be contributing to the problem. The error often happens when the associated app pool is recycled, but it sometimes happens when no recycle is happening. Also, even after the error occurs, it seems that log4net is able to keep logging to the database from that same process. I'm using the default value for the ReconnectOnError property, which the documentation says is false (i.e. log4net should stop logging if the connection is no longer open). So it seems like the connection is still okay. As further evidence, the database connection ID for the process is the same before and after the error. Also, I'm using BufferSize of 1, and the DB connection is via localhost. Thanks, --Chris -- Chris Jerdonek, PhD Software Developer | Product Development Granicus, Inc. w: (415) 357-3618 ext 1357 | c: (415) 286-2238 Changing the way citizens interact with government [71500] log4net:ERROR [AdoNetAppender] Exception while writing to database [71500] MySql.Data.MySqlClient.MySqlException: Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host [71500] at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) [71500] at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) [71500] --- End of inner exception stack trace --- [71500] at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) [71500] at System.IO.BufferedStream.ReadByte() [71500] at MySql.Data.MySqlClient.MySqlStream.LoadPacket() [71500] --- End of inner exception stack trace --- [71500] at MySql.Data.MySqlClient.MySqlStream.LoadPacket() [71500] at MySql.Data.MySqlClient.MySqlStream.OpenPacket() [71500] at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId) [71500] at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet() [71500] at MySql.Data.MySqlClient.MySqlDataReader.NextResult() [71500] at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) [71500] at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() [71500] at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction(IsolationLevel iso) [71500] at MySql.Data.MySqlClient.MySqlConnection.BeginDbTransaction(IsolationLevel isolationLevel) [71500] at System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransacti on() [71500] at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events) [33000] log4net:ERROR [AdoNetAppender] Exception while writing to database [33000] MySql.Data.MySqlClient.MySqlException: Connection unexpectedly terminated. [33000] at MySql.Data.MySqlClient.MySqlStream.LoadPacket() [33000] at MySql.Data.MySqlClient.MySqlStream.OpenPacket() [33000] at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId) [33000] at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet() [33000] at MySql.Data.MySqlClient.MySqlDataReader.NextResult() [33000] at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) [33000] at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() [33000] at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction(IsolationLevel iso) [33000] at MySql.Data.MySqlClient.MySqlConnection.BeginDbTransaction(IsolationLevel isolationLevel) [33000] at System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransacti on() [33000] at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
