Setting ADONetAppender Parameter Layout Parameter in code...

"Adam Patacchiola" <[email protected]> Tue, 23 Mar 2004 14:02:31 -0700
Newsgroups gmane.comp.windows.dotnet.log4net.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------=_NextPart_000_0000_01C410DF.7C72B460
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi,
 
I'm trying to convert my ADONetAppender config file entries to code. The
problem I am having is my parameters are using the PatternLayout to convert
NDC values into parameters, and ADONetAppenderParameter.Layout is expecting
an IRawLayout type, whereas PatternLayout implements the ILayout interface.
How would I go about doing this? My config file is as below.
 
<appender name="AuditAppender" type="log4net.Appender.ADONetAppender">

<param name="BufferSize" value="100" />

<param name="CommandType" value="StoredProcedure"/>

<param name="ConnectionType" value="System.Data.SqlClient.SqlConnection,
System.Data, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />

<param name="ConnectionString" value ="Omitted for posting..." />

<param name="CommandText" value="InsertAuditEntry" />

<param name="Parameter">

<param name="ParameterName" value="@FileID" />

<param name="DbType" value="Int32" />

<param name="Size" value="0" />

<param name="Layout" type="log4net.Layout.PatternLayout">

<param name="ConversionPattern" value="%X{FileID}" />

</param>

</param>

<param name="Parameter">

<param name="ParameterName" value="@UserID" />

<param name="DbType" value="Int32" />

<param name="Size" value="0" />

<param name="Layout" type="log4net.Layout.PatternLayout">

<param name="ConversionPattern" value="%X{UserID}" />

</param>

</param>

<param name="Parameter">

<param name="ParameterName" value="@Description" />

<param name="DbType" value="String" />

<param name="Size" value="1000" />

<param name="Layout" type="log4net.Layout.PatternLayout">

<param name="ConversionPattern" value="%m" />

</param>

</param>

</appender>

 
Thanks,
 
Adam

------=_NextPart_000_0000_01C410DF.7C72B460
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial=20
size=3D2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial size=3D2>I'm =
trying to=20
convert my ADONetAppender config file entries to code. The problem I am =
having=20
is my parameters are using the PatternLayout to convert NDC values into=20
parameters, and ADONetAppenderParameter.Layout is expecting an =
IRawLayout type,=20
whereas PatternLayout implements the ILayout interface. How would I go =
about=20
doing this? My config file is as below.</FONT></SPAN></DIV>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D406425820-23032004>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>appender</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"AuditAppender"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>type</FONT><FONT=20
color=3D#0000ff>=3D"log4net.Appender.ADONetAppender"&gt;</P></FONT></FONT=
>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"BufferSize"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"1<SPAN =
class=3D406425820-23032004>00</SPAN>"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"CommandType"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"StoredProcedure"/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ConnectionType"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"System.Data.SqlClient.SqlConnection, System.Data,=20
Version=3D1.0.5000.0, Culture=3Dneutral,=20
PublicKeyToken=3Db77a5c561934e089"</FONT><FONT color=3D#ff00ff> =
</FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ConnectionString"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT =
color=3D#0000ff><SPAN=20
class=3D406425820-23032004><FONT color=3D#ff0000> =3D"Omitted for =
posting</FONT><FONT=20
color=3D#0000ff>...</FONT></SPAN>"</FONT><FONT color=3D#ff00ff> =
</FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"CommandText"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"InsertAuditEntry"</FONT><FONT color=3D#ff00ff> =
</FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"Parameter"&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ParameterName"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"@FileID"</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"DbType"</FONT><FONT =

color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"Int32"</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"Size"</FONT><FONT =
color=3D#ff00ff>=20
</FONT><FONT color=3D#ff0000>value</FONT><FONT =
color=3D#0000ff>=3D"0"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"Layout"</FONT><FONT =

color=3D#ff00ff> </FONT><FONT color=3D#ff0000>type</FONT><FONT=20
color=3D#0000ff>=3D"log4net.Layout.PatternLayout"&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ConversionPattern"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"%X{FileID}"</FONT><FONT color=3D#ff00ff> =
</FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;/</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#0000ff>&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;/</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#0000ff>&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"Parameter"&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ParameterName"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"@UserID"</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"DbType"</FONT><FONT =

color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"Int32"</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"Size"</FONT><FONT =
color=3D#ff00ff>=20
</FONT><FONT color=3D#ff0000>value</FONT><FONT =
color=3D#0000ff>=3D"0"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"Layout"</FONT><FONT =

color=3D#ff00ff> </FONT><FONT color=3D#ff0000>type</FONT><FONT=20
color=3D#0000ff>=3D"log4net.Layout.PatternLayout"&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ConversionPattern"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"%X{UserID}"</FONT><FONT color=3D#ff00ff> =
</FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;/</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#0000ff>&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;/</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#0000ff>&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"Parameter"&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ParameterName"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"@Description"</FONT><FONT color=3D#ff00ff> =
</FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"DbType"</FONT><FONT =

color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"String"</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"Size"</FONT><FONT =
color=3D#ff00ff>=20
</FONT><FONT color=3D#ff0000>value</FONT><FONT =
color=3D#0000ff>=3D"1000"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT color=3D#0000ff>=3D"Layout"</FONT><FONT =

color=3D#ff00ff> </FONT><FONT color=3D#ff0000>type</FONT><FONT=20
color=3D#0000ff>=3D"log4net.Layout.PatternLayout"&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#ff0000>name</FONT><FONT =
color=3D#0000ff>=3D"ConversionPattern"</FONT><FONT=20
color=3D#ff00ff> </FONT><FONT color=3D#ff0000>value</FONT><FONT=20
color=3D#0000ff>=3D"%m"</FONT><FONT color=3D#ff00ff> </FONT><FONT=20
color=3D#0000ff>/&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;/</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#0000ff>&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;/</FONT><FONT=20
color=3D#800000>param</FONT><FONT color=3D#0000ff>&gt;</P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>&lt;/</FONT><FONT=20
color=3D#800000>appender</FONT><FONT=20
color=3D#0000ff>&gt;</P></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial=20
size=3D2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D406425820-23032004><FONT face=3DArial=20
size=3D2>Adam</FONT></SPAN></DIV></BODY></HTML>

------=_NextPart_000_0000_01C410DF.7C72B460--



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click