I needed to do something very similar.  What I did was to create my own logging class which wraps Log4NET.  This class implements ILogger.  I use the Logger.Log() method to log my message.  The key here is that I then have access to the actual LoggingEvent object.  LoggingEvent contains a PropertiesCollection.  You can use the LoggingEvent.Properties collection to add your own custom values.  For example, LoggingEvent.Properties["MyCustomValue"].  Then, when you need to use it in your ADONETAppender, it is as simple as saying "%P{MyCustomValue}" in your ConversionPattern.
 
I'm not sure if that is the best way, but so far so good.  ;)


From: Patrick Cheng [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 28, 2004 3:46 AM
To: Log4NET User
Subject: Question on Logging customized information

Hi,
I would like to log some data via ADONETAppender into my own log table.
Say, my table LOG has column A(varchar(100)) and B (varchar(100)).
I do not want to log the default information such as %logger %thread %logdate etc...
instead i want to log my own A and B values into the database.
 
I am able to get it done if i only have one value , ie, A, by setting PatternLayout = "%m",
and calling the log.Debug("test"), the "test" will go into the db.
but is there a way to pass in more than 1 value?
(the worst case, i will concatenate A and B into 1 string and break it down in sql statement... but any alternative?)
 
Thank you,
 
Pat

Reply via email to