You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Frode Breimo <fr...@broadpark.no> on 2005/06/08 12:02:05 UTC

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\testdb.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