Null parameters are not supported by the AdoNetAppender in the last
release. Support has since been added to the source code.

You can either build a new copy of log4net from the latest sources from
subversion.
http://logging.apache.org/log4net/contributing.html#svn-anon

If you want to keep using the latest log4net binary then you will need
to build your own copy of the appender in your own assembly. The updated
code for the appender is here:

http://svn.apache.org/viewcvs.cgi/logging/log4net/trunk/src/Appender/Ado
NetAppender.cs?view=markup

Just change the namespace to something appropriate, build it in one of
your assemblies, then set the type="" in the config to be the assembly
qualified type name for the updated appender.

Cheers,
Nicko

> -----Original Message-----
> From: Coates, Anthony [mailto:[EMAIL PROTECTED] 
> Sent: 28 February 2006 09:56
> To: log4net-user@logging.apache.org
> Subject: Setting AdoNetAppender parameters to null
> 
> Hi
> 
> I posted this previously in an earlier thread but haven't 
> received a reply yet so thought I would try it on it's own thread...
> 
>  
> 
>  
> 
> I've been using properties to send several user-defined 
> messages via the ADO.NET appender. This works great except 
> when I'm trying to set a parameter value to DBNull.Value (to 
> set the column value that this parameter relates to to null), 
> e.g. using the command 
> "log4net.GlobalContext.Properties["Message2"] = DBNull.Value;".
> 
>  
> 
> In this case the column in the table is being set to an empty 
> string rather than NULL. This seems to be during the call to 
> AdoNetAppender.SendBuffer when the actual ado.net parameters 
> value is being set.
> 
>  
> 
> The config for this parameter is: 
> 
>  
> 
> <parameter> 
> 
>         <parameterName value="@message2" /> 
> 
>         <dbType value="string" /> 
> 
>         <size value="100"/> 
> 
>         <layout type="log4net.Layout.PatternLayout"> 
> 
>                 <conversionPattern value="%property{Message2}" /> 
> 
>         </layout> 
> 
> </parameter> 
> 
>  
> 
> Is it possible to get it to send DBNull.Value instead so the 
> column value will be set to null? 
> 
>  
> 
> Thanks 
> 
> Ant
> 
> 
> 
> Scanned for viruses by BlackSpider MailControl 
> <http://www.blackspider.com/> . The integrity and security of 
> this message cannot be guaranteed. This email is intended for 
> the named recipient only, and may contain confidential 
> information and proprietary material. Any unauthorised use or 
> disclosure is prohibited.
> 
> 

Reply via email to