You can write a helper method:
public class LogHelper
{
private static void LogInfoWithProperties(ILog log,
string message,
IDictionary properties)
{
if (log.IsInfoEnabled)
{
LoggingEvent loggingEvent = new LoggingEvent(
typeof(LogHelper),
log.Logger.Repository,
log.Logger.Name,
Level.Info,
message,
null);
foreach(DictionaryEntry entry in properties)
{
loggingEvent.Properties[entry.Key.ToString()] = entry.Value;
}
log.Logger.Log(loggingEvent);
}
}
}
> -----Original Message-----
> From: Dalton, Barnaby [mailto:[EMAIL PROTECTED]
> Sent: 13 December 2005 11:58
> To: Log4NET User
> Subject: Setting properties on a logging event
>
> Is there a user accessible way to set some properties for a
> single event? I would like to be able to log event as a list
> of names and values and have these written as separate
> attributes/elements by the XmlLayout class. I can set the
> global properties but this seems a bit clumsy for a single
> event as I have to remove them afterwards.
>
> Thanks
> Barney
>