logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Parkinson" <kevin.parkin...@quercussolutions.com>
Subject Custom Parameters Not Working
Date Wed, 20 Jun 2007 16:29:16 GMT
Hello Everyone:


                I am having a problem getting Log4Net to log because a
particular Guid parameter I am using.


Here is what I have in my config file:



<parameterName value="@messageID" />

                <dbType value="Guid" />

                <size value="10" />

                <layout type="log4net.Layout.PatternLayout"
value="%property{QueryServiceMessageID}" />



Here is my property in code:


 Guid messageID = new Guid("7d32ea24-289c-48d7-9037-7c3caa75a87c");

        log4net.GlobalContext.Properties["QueryServiceMessageID"] =


Here is the stack trace I am getting through internal debugging:


log4net:ERROR [AdoNetAppender] Exception while writing to database

System.InvalidCastException: Failed to convert parameter value from a
String to a Guid. ---> System.InvalidCastException: Invalid cast from
'System.String' to 'System.Guid'.

   at System.Convert.DefaultToType(IConvertible value, Type targetType,
IFormatProvider provider)

   at System.String.System.IConvertible.ToType(Type type,
IFormatProvider provider)

   at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)

   at System.Data.SqlClient.SqlParameter.CoerceValue(Object value,
MetaType destinationType)

   --- End of inner exception stack trace ---

   at System.Data.SqlClient.SqlParameter.CoerceValue(Object value,
MetaType destinationType)

   at System.Data.SqlClient.SqlParameter.GetCoercedValue()

   at System.Data.SqlClient.SqlParameter.Validate(Int32 index)

   at System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser,
SqlParameterCollection parameters)

   at System.Data.SqlClient.SqlCommand.BuildPrepExec(CommandBehavior

cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)

result, String methodName, Boolean sendToPipe)

   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

   at log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran,
LoggingEvent[] events)


Can anyone make any recommendations or point out any errors? Any help is
much appreciated.


Kevin Parkinson


View raw message