You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Dave Hutz <da...@cgadc.com> on 2005/01/25 00:12:55 UTC

ADONetAppender through a firewall

We have been running into trouble while using ADONetAppender to log to a database that is behind a firewall.

In short, the firewall times-out idle connections, and log4net doesn't reconnect to the database once the connection is broken.

I added some code like this, and it seems to fix the problem.

/// <summary>
/// This method determines if there is a sense in attempting to append.
/// </summary>
/// <remarks>
/// <para>
/// This method checks if the db is open.  If it isn't, it opens it.
/// </para>
/// </remarks>
/// <returns><c>false</c> if any of the preconditions fail.</returns>
override protected bool PreAppendCheck()
{
	if (!base.PreAppendCheck())
	{
		return false;
	}
	if (m_dbConnection==null ||
	    m_dbConnection.State!=ConnectionState.Open)
	{
		InitialiseDatabaseConnection();
		InitialiseDatabaseCommand(); //must reinitialize the command if we redo the connection
	}
	return true; //it throws above if it fails
}



Could you include this (or something like it) into the main code?

Thanks,
	Dave