Wanting to Customize Appender for 5 fields

2010-01-02 Thread pe...@peterkellner.net
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:



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
Microsoft MVP * ASPInsider



RE: Wanting to Customize Appender for 5 fields

2010-01-02 Thread pe...@peterkellner.net
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: [email protected] [mailto:[email protected]]
Sent: Saturday, January 02, 2010 9:07 AM
To: [email protected]
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:



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