logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Georg Jansen" <Georg.Jan...@FaktNet.com>
Subject RE: How to pass data to custom ADONetAppender parameters?
Date Thu, 07 Sep 2006 05:42:49 GMT
Sorry, an error in the parameter definition in my previous mail.





Inserting custom data using the AdoNetAppender si pretty straight forward,
first you have to modify the sql statement in the configuration file to
something like:


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


And add a new parameter definition for the custom column for example like:



   <parameterName value="@MyColumn "/>

   <dbType value="String" />

   <size value="255" />

   <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%property{MyColumn}" />




Then you use one of log4net's contexts to transfer values to the parameter
for example:


log4net.GlobalContext.Properties["MyColumn"] = "MyValue";

log.Debug("My message")


Best regards


http://www.l4ndash.com <http://www.l4ndash.com/>  - Log4net Dashboard







-----Original Message-----
From: harry.douglass@pnc.com [mailto:harry.douglass@pnc.com] 
Sent: 6. september 2006 21:18
To: Log4NET User
Subject: How to pass data to custom ADONetAppender parameters?




I am trying to find a way to write my own custom parameters that I would


to a SQL Server Database.   I am a newbie to this, so I got the

"out-of-the-box" implementation of logging an exception, message, dates


writes to SQL Server using the ADONetAppender.  However, I want to pass my

own custom data variables to the database.  So, my DB table would have




Table name = CustomStuff


Custom Log Fields:








I found code that creates a custom ADONetAppender, but there's more to it

and I can seem to bridge even how that would translate into C# code on how

to pass this data in the parameters.


I hope what I am asking makes sense, but if not I can provide more details.


Thanks in advance,





The contents of this email are the property of PNC. If it was not addressed
to you, you have no legal right to read it. If you think you received it in
error, please notify the sender. Do not forward or copy without permission
of the sender. This message may contain an advertisement of a product or
service and thus may constitute a commercial electronic mail message under
US Law. PNCs postal address is 249 Fifth Avenue, Pittsburgh, PA 15222. If
you do not wish to receive any additional advertising or promotional
messages from PNC at this e-mail address, click here to Unsubscribe.
https://pnc.p.delivery.net/m/u/pnc/uni/p.asp By unsubscribing to this
message, you will be unsubscribed from all advertising or promotional
messages from PNC. Removing your e-mail address from this mailing list will
not affect your subscription to alerts, e-newsletters or account servicing

View raw message