logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Patacchiola" <a...@adeptivesw.com>
Subject ADONetAppender problems
Date Tue, 23 Mar 2004 23:20:50 GMT
Hello,

I have created an ADONetAppender using the following code:

		public ADONetAppender CreateADONetAuditAppender() {

			ADONetAppender ado = new ADONetAppender();
			//how many entries to queue up before writing to db
			ado.BufferSize = 1;
			//debugging level
			ado.Threshold = log4net.spi.Level.DEBUG;

			//connection stuff
			ado.CommandType =
System.Data.CommandType.StoredProcedure;
			ado.CommandText = "InsertAuditEntry";
			ado.ConnectionType =
"System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089";			
			ado.ConnectionString = //omitted for posting
			
			//parameters
			ADONetAppenderParameter param = new
ADONetAppenderParameter();
			//file id parameter
			param.ParameterName = "@FileID";
			param.DbType = System.Data.DbType.Int32;
			param.Size = 0;
			param.Layout = new Layout2RawLayoutAdapter(new
log4net.Layout.PatternLayout("$X{FileID}"));
			ado.AddParameter(param);	
			

			//user id parameter
			param = new ADONetAppenderParameter();
			param.ParameterName = "@UserID";
			param.DbType = System.Data.DbType.Int32;
			param.Size = 0;
			param.Layout = new Layout2RawLayoutAdapter(new
log4net.Layout.PatternLayout("$X{UserID}"));
			ado.AddParameter(param);

			//description parameter
			param = new ADONetAppenderParameter();
			param.ParameterName = "@Description";
			param.DbType = System.Data.DbType.AnsiString;
			param.Size = 1000;
			param.Layout = new Layout2RawLayoutAdapter(new
log4net.Layout.PatternLayout("%m"));
			ado.AddParameter(param);		

			ado.ActivateOptions();

			return ado;

		}

However when my program is run I get the following error:

log4net:ERROR [ADONetAppender] Exception while writing to database
System.FormatException: Input string was not in a correct format.
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at log4net.Appender.ADONetAppender.SendBuffer(IDbTransaction dbTran,
LoggingEvent[] events)
   at log4net.Appender.ADONetAppender.SendBuffer(LoggingEvent[] events)

The Description field of my table is a VarChar with length 1000.

What am I doing wrong?

Thanks,

Adam



Mime
View raw message