Søren,

I recently had the same issue, so I'll briefly tell you what I ended up with
(maybe that'll work for you too).

Log4Net actually has a bunch of levels besides those publicly available as
standard. If you provide your own ILog and LoggerWrapperImpl:

public interface ILog : log4net.Core.ILoggerWrapper
public class MyLogImpl : log4net.Core.LoggerWrapperImpl, ILog

and provide your own custom LogManager, you can get access to these other
levels, plus create your own, for instance:

public sealed class LogManager {
        public static log4net.Core.Level Feedback = new
log4net.Core.Level(35000, "FEEDBACK");
}

public class MyLogImpl : log4net.Core.LoggerWrapperImpl, ILog {
...
        virtual public void Feedback(object message) {
                Logger.Log(ThisDeclaringType, m_levelFeedback, message,
null);
        }

...

protected virtual void ReloadLevels(log4net.Repository.ILoggerRepository
repository) {
                log4net.Core.LevelMap levelMap = repository.LevelMap;

                m_levelDebug =
levelMap.LookupWithDefault(log4net.Core.Level.Debug);
                m_levelFeedback =
levelMap.LookupWithDefault(LogManager.Feedback);
                m_levelInfo =
levelMap.LookupWithDefault(log4net.Core.Level.Info);
                m_levelWarn =
levelMap.LookupWithDefault(log4net.Core.Level.Warn);
                m_levelError =
levelMap.LookupWithDefault(log4net.Core.Level.Error);
                m_levelFatal =
levelMap.LookupWithDefault(log4net.Core.Level.Fatal);
        }
...
}

I can send more details from my code directly if you need further direction.

Regards,

Wayne M. Bradney 
Application Architect, Derivatives & Structured Products 
Wall Street Systems 
30 Broad Street, 24th Floor, New York, NY 10004 USA 
Tel: +1 (212) 809 7200 
Fax: +1 (212) 809 7578 
Visit our website at http://www.wallstreetsystems.com 
This transmission may be a privileged or confidential communication. If you
are not the intended recipient, you are hereby notified that you have
received this transmission in error; any review, dissemination, distribution
or copying of this transmission is strictly prohibited. If you have received
this communication in error, please notify us immediately by reply or by
telephone (call us at +1-212-809-7200) and immediately delete this message
and all its attachments.

-----Original Message-----
From: Søren M. Olesen [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 29, 2005 1:50 AM
To: [email protected]
Subject: Custom logging level

Hi

I been trying to figure out how to make a custum debug level, but haven't 
succeded yet...anyone who has an example or know where to find an example, 
that they'd like to share with me....

TIA

Søren



Reply via email to