0

I've written a log4net appender which inherits from a forwarding appender in which I want to edit the loggingEvent like this, so my next set of appenders have the right information.

protected override void Append(LoggingEvent loggingEvent)
    {
        if (loggingEvent.MessageObject.GetType() == typeof(CustomLogObject))
        {
            var logentry = (CustomLogObject)loggingEvent.MessageObject;
            var data = loggingEvent.GetLoggingEventData();
            data.TimeStamp = logentry.toLocalTime();
            data.ThreadName= logentry.url;
            loggingEvent = new LoggingEvent(data);
        }
        base.Append(loggingEvent);
    }

This works fine however, it loses the original messageobject which in my other set of custom appenders causes trouble. Is there a way to edit the timestamp without it losing the original messageobject?

1 Answers1

0

No you can not edit the timestamp because it has no setter. It seems you have to look into your custom appender to fix your issue.

Peter
  • 27,590
  • 8
  • 64
  • 84