logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: database appender
Date Thu, 19 Feb 2009 04:28:32 GMT
You'll need to create the LoggingEvent object yourself and and add those custom properties
to LoggingEvent.Properties. Here's a complete example:


Your implementation doesn't need to be that complex:

// untested
public LogEx : ILog
 private ILog log;
 public LogEx(ILog log)
  this.log = log;

 public void Trace(string message, object oldValue, object newValue)
   var loggingEvent = new LoggingEvent(GetType(), log.Logger.Repository, log.Logger.Name,
Level.Trace, message, null);
   loggingEvent.Properties["OldValue"] = oldValue;
   loggingEvent.Properties["NewValue"] = newValue;

 // snip: delegate the ILog implementation to log

This is how you'd use that in your class:

 private LogEx log = new LogEx(LogManager.GetLogger(typeof(Program)));

----- Original Message ----
From: rodchar <rodchar@hotmail.com>
To: log4net-dev@logging.apache.org
Sent: Wednesday, February 18, 2009 10:30:48 PM
Subject: database appender

hi all,

is it possible to add extra fields to the database row that events get
logged to. For example, a before after snapshot of a gridview record?

View this message in context: http://www.nabble.com/database-appender-tp22093370p22093370.html
Sent from the Log4net - Dev mailing list archive at Nabble.com.

View raw message