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 Kevin Parkinson <ke...@quercussolutions.com> on 2007/05/22 19:54:19 UTC

Customizing Parameter

Hello:

 

     When I make a log entry I would like to add a transaction id to the
database as well ( using AdoNetAppender of course ) so that it allows me
to go back later and trace through a process to see where it succeeded
and where it went wrong. I se there is not problem in specifying this
parameters at run time. Along with the following code in the config
file:

 

<appender name="AdoNetAppender_SqlServer"
type="log4net.Appender.AdoNetAppender">

                                                <connectionType
value="System.Data.SqlClient.SqlConnection, System.Data,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

                                                <connectionString
value="data source=QS-ASEBP-KEVINP;initial catalog=Log4Net;integrated
security=True" />

                                                <commandText
value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message])
VALUES (@log_date, @thread, @log_level, @logger, @message)" />

                                                <parameter>

 
<parameterName value="@log_date" />

                                                                <dbType
value="DateTime" />

                                                                <layout
type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd
HH':'mm':'ss'.'fff}" />

                                                </parameter>

                                                ..........

 

I would put this:

 

<parameter>

<parameterName value="@transactionID" />

                <dbType value="String" />

                <layout type="log4net.Layout.PatternLayout" value="???"
/>

</parameter>

 

That makes sense, but I am having problems finding a way to set the
value of the transactionID parameter at run time. Which leads me to
another question of what to put in the value attribute of the layout for
that parameter. Does anyone have experience with dynamically setting
values of custom parameters at run time? If so, can you share your
insight? Thanks a lot!

 

Kevin Parkinson

Consultant / .NET Developer

Quercus Solutions

Edmonton Alberta Canada