views:

295

answers:

1

Is it possible to log to an XML column in SQL Server using the AdoNetAppender in log4net?

I know that I can treat the column as a string and log that way through:

<parameter>
    <parameterName value="@details" />
    <dbType value="String" />
    <size value="4000" />
    <layout type="log4net.Layout.PatternLayout">
     <conversionPattern value="%property{Details}" />
    </layout>
</parameter>

But, I'd rather log using:

<parameter>
    <parameterName value="@details" />
    <dbType value="Xml" />
    <layout type="log4net.Layout.PatternLayout">
     <conversionPattern value="%property{Details}" />
    </layout>
</parameter>

Unfortunately, that doesn't seem to work.

I'd much rather do the logging using the actual database type instead of taking advantage of the fact that I could just use string.

+1  A: 

The DbType.Xml enum value was introduced in .Net 2.0. After closer inspection of how to use DBType.Xml with ADO.NET it seems that the best way of passing data into an XML column is actually by passing data in as string.

Peter Lillevold
I was a bit quick and missed the fact that a 2.0 compiled version is indeed included in the log4net distribution.
Peter Lillevold