You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by "peter@peterkellner.net" <pe...@peterkellner.net> on 2010/01/02 18:06:39 UTC

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


RE: Wanting to Customize Appender for 5 fields

Posted by "peter@peterkellner.net" <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: peter@peterkellner.net [mailto:peter@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


Configure the debug value to try or false through C# code

Posted by Leo Mathew <le...@sonata-software.com>.
Hi All,

 

We are using log4Net in our application.

We want to make the debugging of statements to be enabled or disabled. 

 

Is it possible to configure this by setting the below debug value to
"true" or "false" through the C# code?

<log4net debug="false">

 

The above line is from log4Net.config file.

 

Regards,

Leo