Title: RE: ADO.NET appender parameters

I've been using the property example below to send several user-defined messages via ADO.NET appender. This works great except when I'm trying to set a parameter value to DBNull.Value. (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 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 send DBNull.Value instead?

Thanks
Ant



-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2006 00:15
To: Log4NET User
Subject: Re: ADO.NET appender parameters

What exactly do you want to send?

This is the example from the website:

 <parameter>
  <parameterName value="@thread" />
  <dbType value="String" />
  <size value="255" />
  <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%thread" />
  </layout>
 </parameter>

Here's an example of how to send data using a property:

 log4net.GlobalContext.Properties["Today"] = DateTime.Today;
 log.Debug("this is my message");

 <parameter>
  <parameterName value="@today" />
  <dbType value="Date" />
  <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%property{Today}" />
  </layout>
 </parameter>

--- "Coates, Anthony" <[EMAIL PROTECTED]> wrote:

> Hi
>
> I would like to perform some logging with the AdoNetAppender using
> custom
> parameters and values (i.e. not just using a built in value like
> %thread) so
> that I can, in effect, send several user defined messages (other than
> just
> %message) to separate parameters of the stored procedure with a log.
> I've
> noticed in a recent mail the use of
> loggingEvent.Properties["@textData1"] =
> "some string" but am not sure how I can get hold of the loggingEvent
> prior
> to calling the logger (if that's how it's done). Any suggestions with
> example code & config would be much appreciated.
>

>
> Cheers
>
> Ant
>
>
>
> Scanned for viruses by BlackSpider MailControl. 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.
>



Scanned for viruses by BlackSpider MailControl. 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