http://www.google.com/search?q=AdoNetAppender+custom+parameter

http://www.mail-archive.com/[email protected]/msg03380.html

Georg Jansen offered this solution:

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

log4net.GlobalContext.Properties["MyColumn"] = "MyValue";
log.Debug("My message");

----- Original Message ----

From: Kevin Parkinson <[EMAIL PROTECTED]>

To: [email protected]

Sent: Tuesday, May 22, 2007 1:54:19 PM

Subject: 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

     

     

     

     

   

  







Reply via email to