Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4net and ints

I have been working a bit with log4net and have been inserting extra fields, but I have problems with adding int fields. Could anyone show a configuration where an int is used, since I have not been able to find it on their homepage.

I normally just use a configuration like:

 <parameter>
        <parameterName value="@orderid" />
        <dbType value="string" />
        <size value="64" />
        <layout type="log4net.Layout.PatternLayout" />
    </parameter>

But it would be more optimal for searching in the log database if this field could have been an int instead.

like image 895
Dofs Avatar asked Dec 04 '09 09:12

Dofs


2 Answers

Just changing it to Int32 did not fix the issue for me. For others looking to solve this problem, here's the solution:

        <parameter>
            <parameterName value="@UserID" />
            <dbType value="Int32" />
            <size value="32" />
            <layout type="log4net.Layout.RawPropertyLayout">
                <key value="UserID" />
            </layout>
        </parameter>

This will also deal with NULLs

like image 141
KShan Avatar answered Oct 05 '22 23:10

KShan


The dbType property is of type System.Data.DbType. There, you can use the Int32 value to represent integers.

like image 43
Peter Lillevold Avatar answered Oct 05 '22 23:10

Peter Lillevold