I have adonetappender configured in my .net application for some parameters i have a fixed length in database for the column but in my logging data length get exceeded. From log4net trace log i find error as
log4net:ERROR [AdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database
MySql.Data.MySqlClient.MySqlException: Data too long for column 'action' at row 1
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId)
at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int32& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
log4net: Shutdown called on Hierarchy [log4net-default-repository]
parameter in my log4net config is as follows
<parameter>
<parameterName value="action" />
<dbType value="String" />
<size value="45" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5c{1}.%M" />
</layout>
</parameter>
Any idea i can handle the max length in config ?
I would suggest to increase the column length, since you would loose your log.
If you want your log to be fixed size, then your setting should work. OR set it to "-1" or remove size property completely, that way it would now depend on length of your table column.
Also if you are using stored procedure, I realized that you are missing "@"