Figured out what I needed:

       protected override void Append(LoggingEvent loggingEvent)
        {
            string batchMsg = RenderLoggingEvent(loggingEvent);
            //Console.WriteLine(str);

            var qDataLog4Net =
                new QDataLog4Net()
                    {
                        Level = loggingEvent.Level.Name,
                        LoggerName = loggingEvent.LoggerName,
                        ThreadName = loggingEvent.ThreadName,
                        UserName = loggingEvent.UserName,
                        TimeStampOfLog = loggingEvent.TimeStamp,
                        MessageObject = loggingEvent.RenderedMessage
                    };

From: pe...@peterkellner.net [mailto:pe...@peterkellner.net]
Sent: Saturday, January 02, 2010 9:07 AM
To: log4net-user@logging.apache.org
Subject: Wanting to Customize Appender for 5 fields

I'm writing a log4net to MSMQ appender and have followed the the simple 
directions to inherit from AppenderSkeleton and override the Append method.  
I've done that with the following two lines of code:

protected override void Append(LoggingEvent loggingEvent)
        { string batchMsg = RenderLoggingEvent(loggingEvent);

Then, I've made my ConversionPattern as folows:

<conversionPattern value=" 
%newline%TOP-OF-LOG4NET-MESSAGE***%newline%date%newline%thread%newline%level%newline%logger%newline%message%newline"
 />

With this plan, I have to write a parser to look for new lines which might be a 
problem if there are new lines in my messages.

I'd like to be able to specify in the Appender directly the variables from the 
log4netMessage (date;thread;level,etc.).  I'd appreciate if someone could give 
me some specific guidance on how to do this as simple as possible.


Peter Kellner
http://peterkellner.net<http://peterkellner.net/>
Microsoft MVP * ASPInsider

Reply via email to