There is an issue with NULL columns which has been fixed in CVS. See:
http://issues.apache.org/jira/browse/LOG4NET-28?page=all 

Even with this fix you will need to use parameters as in:
http://logging.apache.org/log4net/release/config-examples.html#adonetapp
ender-mssql

Rather than using the PatternLayout you need to use the
log4net.Layout.RawPropertyLayout which retrieves the property value as
an object.

As an alternative you can build your own appender in your library. A
simple appender that logs to a database should be very simple to
implement, an example can be found here:
http://cvs.apache.org/viewcvs.cgi/logging-log4net/examples/net/1.0/Appen
ders/SampleAppendersApp/cs/src/Appender/FastDbAppender.cs?rev=1.1&view=m
arkup

Cheers,
Nicko


> -----Original Message-----
> From: Frode Breimo [mailto:[EMAIL PROTECTED] 
> Sent: 08 June 2005 11:02
> To: Log4NET User
> Subject: Problem with empty properties and AdoNetAppender
> 
> Hi
> 
> I'm using LogicalThreadContext.Properties to store additional 
> data to be logged to my database. There is a problem however, 
> with properties that haven't been set, or have been set to 
> null values. When building the command text log4net inserts 
> the string value "(null)" for these properties. For text 
> columns this is annoying but not a big deal, but for any 
> numeric columns this will cause an exception and the entry 
> will not be logged.
> 
> My appender declaration is
>     <appender name="MTBS" type="log4net.Appender.ADONetAppender" >
>         <connectionType value="System.Data.Odbc.OdbcConnection,
> System.Data, version=1.0.5000.0, 
> publicKeyToken=b77a5c561934e089, culture=neutral" />
>         <connectionString value="DRIVER=Firebird/Interbase(r)
> driver;UID=sysdba;PWD=masterkey;DBNAME=127.0.0.1:w:\data\testd
> b.fdb" />
>         <layout type="log4net.Layout.PatternLayout">
>             <conversionPattern value="INSERT INTO LOG 
> (LOGDATE, LOGLEVEL, LOGMESSAGE, TESTINT) VALUES ('%date', 
> '%level', '%message', '%property{TestInt}')" />
>         </layout>
>     </appender>
> 
> Is there any way around this? (I've tried appender parameters 
> but can't get them to work at all, don't know if they would 
> make a difference regarding this though)
> 
> 
> -Frode
> 
> 
> 

Reply via email to