logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dag Christensen" <Dag.Christen...@vbd.no>
Subject RE: Adding custom level
Date Thu, 08 Jul 2004 07:38:23 GMT
I use appx this code to enable verbose logging (more detailed than
debug). I haven't managed to, or tried very hard to, enable "verbose"
logging using my log4net configuration file - any tips here is greatly
appreciated. Verbose logging is only used by our developers while
debugging code so the current code using an already existing separate
configuration file works well.

    class VBDLog : IVBDLog  // interface defines Verbose,Debug,Info
(...) methods
        public static IVBDLog GetLogger(Type t)
            Level level = log4net.spi.Level.VERBOSE; // actually read
from an external configuration file.
            ILog logger = log4net.LogManager.GetLogger(t);
            if (logger.Level == null)
                logger.Additivity = true;
                logger.Level = level;
            return logger;
        public void Verbose(object msg)
            logger.Logger.Log( logger.Logger.Name,
log4net.spi.Level.VERBOSE, msg);
Client code:

private static readonly IVBDLog log =

if (log.IsVerboseEnabled)

Trace is also a predefined level in log4net just like Verbose (see the
Level class)

I hope this helps,


-----Original Message-----
From: Nik Hassan [mailto:Nik.Hassan@Siebel.com] 
Sent: Wednesday, July 07, 2004 7:24 PM
To: Log4NET User; log4net-user-info@logging.apache.org;
Subject: Adding custom level


How do I add custom level , like TRACE on top of existing log4net levels
I know that in log4j, I can extend Level class.
Does anybody have sample code for log4net to do this ? 

Thank you,

View raw message