I think I can see from the documentation how to specify that I'm using
an sproc. But I can't see what the sproc should do.

Is there an example in the documentation of how to use an sproc with
log4net?

-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 25, 2005 5:32 PM
To: Log4NET User
Subject: RE: Null values for int (revised)

Perhaps you can use a stored procedure to write you logs to the database
instad of a simple INSERT statment.

--- Howard Weisberg <[EMAIL PROTECTED]> wrote:
> I'm logging data using AdoNetAppender_SqlServer. Some of the info I 
> want to log is best expressed in SQL columns of the int data type. 
> Also some of the information is only defined during certain events.
> 
> Ideally, when I log other events, the undefined int information should

> be shown as SQL nulls. However so far I've only been able to figure 
> out how to log int values using a "magic" numerical value (in my case
> zero)
> to flag undefined values. 
> 
> Null values do seem to be supported for string data.
> 
> The following doesn't work for me. It causes the SQL exception "data 
> is not in the correct format."
> 
> int spid = MyGetSPID (transaction);
> log4net.GlobalContext.Properties["spid"] = spid; transaction.Commit();

> EventLog.Info ("Database Updated"); 
> log4net.GlobalContext.Properties["spid"] = null;
> //log4net.GlobalContext.Properties.Remove("spid") also doesn't work.
> 
> Instead I have to use the following:
> 
> const int UNDEFINED_VALUE = 0;
> int spid = MyGetSPID (transaction);
> log4net.GlobalContext.Properties["spid"] = spid; transaction.Commit();

> EventLog.Info ("Database Updated"); 
> log4net.GlobalContext.Properties["spid"] = UNDEFINED_VALUE;
> 
> My config file includes the following:
> 
> <commandText value="INSERT INTO EventLog ([Date], ..., [SPID]) VALUES 
> (@date, ..., @spid)" /> <parameter>
>       <parameterName value="@date" />
>       <dbType value="DateTime" />
>       <layout type="log4net.Layout.PatternLayout"
> value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" /> </parameter>
> 
> ...
> 
> <parameter>
>       <parameterName value="@spid" />
>       <dbType value="Int32" />
>       <layout type="log4net.Layout.PatternLayout"
> value="%property{spid}" /> </parameter>
> 
> My table includes the following:
> 
> CREATE TABLE EventLog
> (
>   [ID] [int] IDENTITY (1, 1) NOT NULL ,
>   [Date] [datetime] NOT NULL ,
> 
> ...
> 
>   [SPID] [int]
> )
> 
> How do I get log4net to handle null integer values? 
> 
> The information contained in this e-mail and any attached documents 
> may be privileged, confidential and protected from disclosure.  If you

> are not the intended recipient you may not read, copy, distribute or 
> use this information.  If you have received this communication in 
> error, please notify the sender immediately by replying to this 
> message and then delete it from your system.
> 

The information contained in this e-mail and any attached documents
may be privileged, confidential and protected from disclosure.  If you
are not the intended recipient you may not read, copy, distribute or
use this information.  If you have received this communication in
error, please notify the sender immediately by replying to this
message and then delete it from your system.

Reply via email to